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