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: Thu, 15 Aug 2024 23:33:42 +0200
User-agent: s-nail v14.9.25-599-g5c75a327b2

One more, please.
(And please excuse this still copies bug-bash.)

Steffen Nurpmeso wrote in
 <20240815184858.r5T_UQnM@steffen%sdaoden.eu>:
 |Steffen Nurpmeso wrote in
 | <20240814200534.Vh3Eu_Md@steffen%sdaoden.eu>:
 ||Chet Ramey wrote in
 || <1bba673e-5ab9-4263-9d88-124854793b4b@case.edu>:
 |||On 8/13/24 8:45 PM, Steffen Nurpmeso wrote:
 |||> I include bug-bash even though i think bash is correct, but there
 |||> lots of people of expertise are listening, so, thus.
 |||> Sorry for cross-posting, nonetheless.
 ...
 |In fact Geoff Clare (who we all deserve thanks, together with Don
 |Cragun, for continued ISO C compiler support for the BSD socket
 |interface we all use in at least POSIX environments, it is
 |undefined anywhere else!, and more) sees this differently:
 |
 |  The standard clearly requires "$@$@" to generate zero fields if
 |  there are no positional parameters. The quoted text "if the
 |  expansion is embedded within a word which contains one or more
 |  other parts that expand to a quoted null string, ..." does not
 |  apply because there are no other parts that expand to a quoted
 |  null string. (The second $@ is not a candidate for being such
 |  a part because "the expansion of '@' shall generate zero
 |  fields".)
 |
 |  If this does not match existing behaviour in some shells, we
 |  could consider making it unspecified, but the first step should
 |  be to alert the maintainers of those shells to the issue and
 |  find out whether they are willing to change their shell to
 |  comply with the standard.
 |
 |So please any shell maintainer listening here, please feel
 |alerted.

I have extended the test a bit, and i also see word split
differences.  Call me idiotic, but .. there seems some state
machinery bug in dash / busybox sh, maybe.

So if i save the code below into a file named t.sh, and if i run
"sh t.sh", then i only get the "$@$@" differences this thread is
about.  But if i run "sh t.sh X" then i get an additional

  1,1=ja "da du $j" ich,2=,3=,4=,5=,6=,7=,8=,9=,                                
                 | 5,1=ja,2="da,3=du,4=$j",5=ich,6=,7=,8=,9=,
  .. 5,1=ja "da du $j" ichja "da du $j" 
ichja,2="da,3=du,4=$j",5=ich,6=,7=,8=,9=,                | .. 
13,1=ja,2="da,3=du,4=$j",5=ichja,6="da,7=du,8=$j",9=ichja,

difference in between dash+ (left) and bash (right).
Now i am looking for too long on these, but can anyone reproduce
this on another machine?  I *can* reproduce it on an AlpineLinux
[edge] vserver.  Ie

  sh t.sh > .A
  bash t.sh > .B
  diff -u .A .B > .D1
  sh t.sh X > .A
  bash t.sh X > .B
  diff -u .A .B > .D2

(Must be said that diffutils diff(1) gives different hunks than
busybox diff, but that aside.)

  y() { echo ".. $#,1=$1,2=$2,3=$3,4=$4,5=$5,6=$6,7=$7,8=$8,9=$9,"; }
  x() { echo "$#,1=$1,2=$2,3=$3,4=$4,5=$5,6=$6,7=$7,8=$8,9=$9,"; y "$@$@"$@; }
  i='ja "da du $j" ich' j=recur

  if [ $# -eq 1 ]; then
  echo =1=
  x ja "da du $j" ich
  x ja:"da du $j":ich
  x $i
  x "$i"
  eval x $i
  eval x "$i"
  x ''
  eval x ''
  echo =2=
  IFS=: x ja "da du $j" ich
  IFS=: x ja:"da du $j":ich
  IFS=: x $i
  IFS=: x "$i"
  IFS=: eval x $i
  IFS=: eval x "$i"
  IFS=: x ''
  IFS=: eval x ''
  fi
  echo =3=
  IFS=': ' x ja "da du $j" ich
  IFS=': ' x ja:"da du $j":ich
  IFS=': ' x $i
  IFS=': ' x "$i"
  IFS=': ' eval x $i
  IFS=': ' eval x "$i"
  IFS=': ' x ''
  IFS=': ' eval x ''
  if [ $# -eq 1 ]; then
  echo =4=
  i=
  x $i
  x "$i"
  eval x $i
  eval x "$i"
  fi

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]