On Wed, Jun 11, 2008 at 10:34:56PM -0400, Sebastien Roy wrote:
> * Since it's possible that a field value could contain a literal
> "|", parseable output will escape literal "|" as "\|", and
> literal "\" as "\\". As it happens, this escape format is
> already handled automatically by the "read" and "while read"
> shell constructs, ensuring that parsing remains simple.
% print ${.sh.version}
Version M 1993-12-28 s+
% function d {
typeset OIFS=$IFS
typeset IFS='|'
read line
set -- $line
IFS=$OIFS
for i in "$@"
do
print -r -- arg: "$i"
done
}
% echo 'a\|b|c'
a\|b|c
% echo 'a\|b|c' | d
arg: a
arg: b
arg: c
% function d {
typeset OIFS=$IFS
typeset IFS='|'
read -r line
set -- $line
IFS=$OIFS
for i in "$@"
do
print -r -- arg: "$i"
done
}
% echo 'a\|b|c' | d
arg: a\
arg: b
arg: c
%
Nico
--