coreutils
[Top][All Lists]
Advanced

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

Re: [PATCH] tests: use printf, not echo in init.sh's warn_ function


From: Jim Meyering
Subject: Re: [PATCH] tests: use printf, not echo in init.sh's warn_ function
Date: Thu, 16 Jun 2011 09:00:08 +0200

Voelker, Bernhard wrote:

> Jim Meyering wrote:
>> James Youngman wrote:
>>> ( IFS=' '; printf '%s\n' "$*"; )
>>>
>>> is perhaps slightly more reproducible.
>>
>> Good suggestion.  Setting IFS does seem prudent.
>> However, I'm inclined to use a subshell only if necessary:
>>
>> warn_ ()
>> {
>>   case $IFS in
>>     ' '*)         printf '%s\n' "$*" 1>&$stderr_fileno_   ;;
>>     *) ( IFS=' '; printf '%s\n' "$*" 1>&$stderr_fileno_ ) ;;
>>   esac
>> }
>
> is a subshell really needed to change IFS?
>
>   warn_ ()
>   {
>     IFS=' ' printf '%s\n' "$*" 1>&$stderr_fileno_
>   }
>
> or don't all shells understand this?

That would be better -- if it worked.
IFS is a shell variable, not an environment variable.
Try this on the command line:

  stderr_fileno_=2
  warn_ () { IFS=' ' printf '%s\n' "$*" 1>&$stderr_fileno_; }

  $ (IFS=:; warn_ a b)
  a:b



reply via email to

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