[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: IFS=: & splitting paths -- (maybe fixed in 4.3?)

From: Greg Wooledge
Subject: Re: IFS=: & splitting paths -- (maybe fixed in 4.3?)
Date: Mon, 9 Mar 2015 08:26:55 -0400
User-agent: Mutt/

On Sun, Mar 08, 2015 at 11:21:41AM -0600, Eduardo A. Bustamante López wrote:
> > alias rs="IFS=\ $'\x09'$'\x0a'" 
> The fuck? Just use 
> alias rs="IFS=\$' \t\n'" or even better, alias rs='unset IFS'

rs() { IFS=$' \t\n'; }

Aliases... my god, why?

> > echo "1st try to split pth:"
> > IFS=: echo $pth
> This *obviously* doesn't work.

See also http://mywiki.wooledge.org/BashFAQ/104 .

If you want pth to be treated as a list, and get split into words,
then store it as an array in the first place, and use "address@hidden"
to extract the words.

pth=(These are my "possibly space-including" words.)
printf '<%s> ' "address@hidden"; echo

There is no need to mess with IFS.

Now, if you're talking about PATH and not pth, then there may be some
reason.  To convert PATH into an array of directories, use something
like this:

IFS=: read -ra pth <<< "$PATH"

Then you can use "address@hidden" to extract the full list, etc.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]