Bug#807011: ksh: Conditional variable expansion problem in while loop
Hi, On Sat, 05 Dec 2015 08:03:32 +0900, Nicholas Bamber wrote: > It is not releveant how this works in other shells (or even other > versions of ksh). All that matters is whether this syntax is defined by the > POSIX standard. It's not even documented as a bash feature let alone a POSIX > standard. The POSIX standard defines ${parameter+word} behavior: http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06_02 and old ksh 93s+20080202-1 (Debian jessie, squeeze) behaves as I and POSIX standard expected. > It may be of interest to you to be reminded that this version of ksh is > dead upstream, so even if I agreed it really was a problem it is very > possible the most I would do is tag it confirmed. > > As it is I believe you are trying to use an undocumented syntax that > just happens to do something you like in lots of other shells. I would > however be interested to know what YOU think the "${v+set}" syntax should do. No. I use the documented syntax. Regards, -- -- Name: SATOH Fumiyasu @ OSS Technology Corp. (fumiyas @ osstech co jp) -- Business Home: http://www.OSSTech.co.jp/ -- GitHub Home: https://GitHub.com/fumiyas/ -- PGP Fingerprint: BBE1 A1C9 525A 292E 6729 CDEC ADC2 9DCA 5E1C CBCA
Bug#807011: ksh: Conditional variable expansion problem in while loop
Satoh, It is not releveant how this works in other shells (or even other versions of ksh). All that matters is whether this syntax is defined by the POSIX standard. It's not even documented as a bash feature let alone a POSIX standard. It may be of interest to you to be reminded that this version of ksh is dead upstream, so even if I agreed it really was a problem it is very possible the most I would do is tag it confirmed. As it is I believe you are trying to use an undocumented syntax that just happens to do something you like in lots of other shells. I would however be interested to know what YOU think the "${v+set}" syntax should do. On 04/12/15 10:15, SATOH Fumiyasu wrote: Hi, The problem seems to be that you are using "${v+set}" rather than "${v}set" . No. Do you understand what does "${v+set}" mean? Please reopen this bug. I want use this trick to avoid additional first blank line in the following script with ksh: https://github.com/fumiyas/fumiyas.github.io/blob/master/2015/12/02/ldifunwrap.sh On Solaris 10: $ uname -a SunOS build-sol10 5.10 Generic_144501-19 i86pc i386 i86pc $ for s in '' ba k z; do sh=${s}sh echo -n $sh: seq 4 |${s}sh -c 'unset v; while read n; do [ -n "${v+set}" ] && printf "%s " "$v "; v="$n"; done; echo "$v"' done sh:1 2 3 4 bash:1 2 3 4 ksh:1 2 3 4 zsh:1 2 3 4 On AIX 6.1: $ uname -a AIX build-aix6 1 6 00CF28B34C00 $ for s in '' ba k z; do sh=${s}sh echo -n $sh: seq 4 |${s}sh -c 'unset v; while read n; do [ -n "${v+set}" ] && printf "%s " "$v "; v="$n"; done; echo "$v"' done sh:1 2 3 4 bash:1 2 3 4 ksh:1 2 3 4 zsh:1 2 3 4
Bug#807011: ksh: Conditional variable expansion problem in while loop
Hi, > The problem seems to be that you are using "${v+set}" rather than > "${v}set" . No. Do you understand what does "${v+set}" mean? Please reopen this bug. I want use this trick to avoid additional first blank line in the following script with ksh: https://github.com/fumiyas/fumiyas.github.io/blob/master/2015/12/02/ldifunwrap.sh On Solaris 10: $ uname -a SunOS build-sol10 5.10 Generic_144501-19 i86pc i386 i86pc $ for s in '' ba k z; do sh=${s}sh echo -n $sh: seq 4 |${s}sh -c 'unset v; while read n; do [ -n "${v+set}" ] && printf "%s " "$v "; v="$n"; done; echo "$v"' done sh:1 2 3 4 bash:1 2 3 4 ksh:1 2 3 4 zsh:1 2 3 4 On AIX 6.1: $ uname -a AIX build-aix6 1 6 00CF28B34C00 $ for s in '' ba k z; do sh=${s}sh echo -n $sh: seq 4 |${s}sh -c 'unset v; while read n; do [ -n "${v+set}" ] && printf "%s " "$v "; v="$n"; done; echo "$v"' done sh:1 2 3 4 bash:1 2 3 4 ksh:1 2 3 4 zsh:1 2 3 4 -- -- Name: SATOH Fumiyasu @ OSS Technology Corp. (fumiyas @ osstech co jp) -- Business Home: http://www.OSSTech.co.jp/ -- GitHub Home: https://GitHub.com/fumiyas/ -- PGP Fingerprint: BBE1 A1C9 525A 292E 6729 CDEC ADC2 9DCA 5E1C CBCA
Bug#807011: ksh: Conditional variable expansion problem in while loop
Package: ksh Version: 93u+20120801-2 Severity: important $ for s in '' ba da k mk z; do sh=${s}sh echo -n $sh: seq 4 |${s}sh -c 'unset v; while read n; do [ -n "${v+set}" ] && echo -n "$v "; v="$n"; done; echo "$v"' done sh:1 2 3 4 bash:1 2 3 4 dash:1 2 3 4 ksh:4 mksh:1 2 3 4 zsh:1 2 3 4 `[ -n "${v+set}" ] ` must be true on 2nd iteration and later in all *sh, but only ksh returns the false on all iteration. -- -- Name: SATOH Fumiyasu @ OSS Technology Corp. (fumiyas @ osstech co jp) -- Business Home: http://www.OSSTech.co.jp/ -- GitHub Home: https://GitHub.com/fumiyas/ -- PGP Fingerprint: BBE1 A1C9 525A 292E 6729 CDEC ADC2 9DCA 5E1C CBCA