bug-bash
[Top][All Lists]
Advanced

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

Re: Question on $@ vs $@$@


From: Steffen Nurpmeso
Subject: Re: Question on $@ vs $@$@
Date: Sun, 25 Aug 2024 04:08:58 +0200
User-agent: s-nail v14.9.25-599-g5c75a327b2

Steffen Nurpmeso wrote in
 <20240825013311.B3Z3QcNn@steffen%sdaoden.eu>:
 |Robert Elz wrote in
 | <26326.1724474200@jacaranda.noi.kre.to>:
 ||    Date:        Fri, 23 Aug 2024 23:47:06 +0200
 ||    From:        Steffen Nurpmeso <steffen@sdaoden.eu>
 ||    Message-ID:  <20240823214706.oskn9OEF@steffen%sdaoden.eu>
 ||
 ||| So IFS whitespace only if part of $IFS.
 ||
 ||That is the definition of IFS whitespace.
 ||
 ||| So this "adjacent" even if *not* part of $IFS.
 ||
 ||No, only characters that are in IFS are ever delimiters (really terminat\
 ||ors).
 ||
 ||| So this means that *regardless* of whatever $IFS is, the three IFS
 ||| whitespace characters are $IFS anyway *if* that is set to
 ||| a nin-empty non-default value.
 ||
 ||No.   Only if they are in IFS.   If we have IFS=': ' then colon and
 ||space are IFS characters, space is IFS whitespace, and tab and newline
 ||are simply characters.
 |
 |Hm i have to think about this on Monday.  That is not what i read
 |from the standard, and here it started working once i checked
 |those in addition in the case where IFS is set non-NUL and
 |non-default.

Ah sigh, many problems where because our variable expansion of $*
always used SPACE as separator (when resolved as variable, not as
individual members).
One hopefully last thing in this regard for me,

  c() { echo "$# 1<$1> 2<$2> 3<$3> *<$*> @<$@>"; }
  set -- a\ b c\ d e\ f
..
  echo 3
  IFS=
  c $*
  c $@
  c "$*"
  c "$@"
..

gives a diff of

   3
  -3 1<a b> 2<c d> 3<e f> *<a bc de f> @<a b c d e f>
  -3 1<a b> 2<c d> 3<e f> *<a bc de f> @<a b c d e f>
  +1 1<a bc de f> 2<> 3<> *<a bc de f> @<a bc de f>
  +1 1<a bc de f> 2<> 3<> *<a bc de f> @<a bc de f>
   1 1<a bc de f> 2<> 3<> *<a bc de f> @<a bc de f>
   3 1<a b> 2<c d> 3<e f> *<a bc de f> @<a b c d e f>

So here the unquoted $* is expanded with $IFS=NUL, the variable $*
was resolved to the string "a bc de f" because the first character
of $IFS is NUL; this string gets the word split, but since no
character of $IFS ever matches (but the terminating NUL), no split
occurs.  How is the shell capable to reconstruct the original
parameters "a b", "c d", and "e f", as there is no field
separator.
(The only thinkable answer is that the step that my MUA does,
namely resolving $* as a single string first, does not happen,
right?  I really have to carefully read the standard on Monday.)

  ...

Thanks again, and
Ciao,

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)



reply via email to

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