l0b0/trim — Issue #1: Base on .bash_aliases
Author: l0b0
Created: 2012-02-16 13:04:49+00:00
State: open

Should use [existing code](https://github.com/l0b0/tilde/blob/e7ccc9a6a3aba2b0216c8e5141554e8a729389ec/.bash_aliases#L326) *but* use the last character of `IFS` as the [line separator](http://tldp.org/LDP/abs/html/internalvariables.html#IFSREF).

Shabby outline code:

ltrim()
{
# Left-trim lines in stdin
local trimmed
local line_separator="${IFS: -1}"
while read -r -u 9
do
printf %s "${REPLY#"${REPLY%%[!$IFS]*}"}"
printf "${line_separator:-\x00}"
done 9<&0

if [[ $REPLY ]]
then
# No delimiter at last line
printf %s "${REPLY#"${REPLY%%[!$IFS]*}"}"
fi
}