bug-bash
[Top][All Lists]
Advanced

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

Re: IFS boundary behaviour is not consistent passing arguments to a func


From: Greg Wooledge
Subject: Re: IFS boundary behaviour is not consistent passing arguments to a function for bash 4.3 or 4.4 .
Date: Tue, 3 Oct 2017 11:30:46 -0400
User-agent: NeoMutt/20170113 (1.7.2)

On Tue, Oct 03, 2017 at 03:26:03AM +0000, McCue, Glenn (SSC/SPC) wrote:
> ## list arguments in the function call.
> echo "first_arg=$first_arg"
> echo "RESULT_A=\`doit \"\$first_arg\":2:3:4:\$PATH\'"
> OIFS=$IFS

What on EARTH is this nonsense?

Pass arguments to commands by quoting them properly.

myfunc "$arg1 "argument two" "${lotsofargs[@]}"

http://mywiki.wooledge.org/Quotes
http://mywiki.wooledge.org/BashFAQ/005

The content of IFS should be irrelevant for 95% of your script.  It
should only be used when you explicitly set it, e.g. for the duration
of a single read command.

IFS=: read -r user hash uid gid gecos home shell < /etc/passwd

http://mywiki.wooledge.org/IFS
http://mywiki.wooledge.org/Arguments



reply via email to

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