[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bug in [ -d ... ] ?
From: |
Greg Wooledge |
Subject: |
Re: Bug in [ -d ... ] ? |
Date: |
Fri, 3 Nov 2017 08:21:41 -0400 |
User-agent: |
NeoMutt/20170113 (1.7.2) |
On Fri, Nov 03, 2017 at 10:29:13AM +0700, Robert Elz wrote:
> if [ -d "${FOOFOOFOO:=""}" ]; ...
>
> is not really portable. In bash, and several other shells, it does what
> it looks like it should do, but in posix (as it stands today) and in some
> other shells, including the original Bourne shell, that is parsed as
>
> if [ -d "${FOOFOOFOO:=""}" ]; ...
> ^=============v^=v
I am not seeing any evidence of this.
wooledg:~$ bash
wooledg:~$ /home/wooledg/bin/args "${FOO:=""}"
1 args: <>
wooledg:~$ sh
$ /home/wooledg/bin/args "${FOO:=""}"
1 args: <>
$ ssh root@imadev
... (c)Copyright 1983-1996 Hewlett-Packard Co., All Rights Reserved. ...
# exec ksh
# /home/wooledg/bin/args "${FOO:=""}"
1 args: <>
# /usr/old/bin/sh
# /home/wooledg/bin/args "${FOO:=""}"
1 args: <>
That's bash 4.4, dash 0.5.8, ksh88 on HP-UX 10.20, and a Bourne shell on
HP-UX 10.20, respectively.