help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] (no subject)


From: Chet Ramey
Subject: Re: [Help-bash] (no subject)
Date: Fri, 22 Sep 2017 11:47:57 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.3.0

On 9/22/17 11:43 AM, John McKown wrote:

>     > $ IFS="" lista=$(cat list)
>     > $ echo $lista
>     > hello
>     > world
> 
>     This leaves IFS set to the empty string, which might lead to unexpected
>     results for subsequent commands.
> 
> 
> ​My bad. I overlooked that. I was thinking that since I didn't do an
> "export IFS", that the variable only retained its value during the
> execution of that one line. 

It's an assignment statement like any other, and there are no commands
other than assignment statements on that line, so all the assignments
affect the current shell.

If there is a command preceded by an assignment statement:

> $ IFS="-" : do nothing
> $ echo -n $IFS|od -tcx1
> 0000000

the assignment only lasts for the duration of the command (posix
alters those semantics somewhat).

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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