tech-userlevel archive

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

Re: /bin/sh tilde expansion

On 14-Jul-08, at 3:00 PM, Jan Schaumann wrote:

When exactly does /bin/sh's tilde expansion take place?

$ /bin/sh -x
$ export DIR=~/tmp
+ export DIR=~/tmp
$ ls -ld $DIR
+ ls -ld ~/tmp
ls: ~/tmp: No such file or directory
$ cd
+ cd
$ ls -ld tmp
+ ls -ld tmp
drwx------  2 jschauma  users  512 Jul  4 21:37 tmp
$ ^D

It seems tilde expansion is broken for /bin/sh (on NetBSD-4 at least) when the command is "export".

It works fine if the variable is set first without the "export":

        15:14 [1] $ /bin/sh
        $ foobar=~/tmp
        $ echo $foobar
        $ export foobar
        $ echo $foobar
        $ ^D15:15 [2] $

/bin/ksh and ksh93 from pkgsrc both also work as expected.

Note that in the original Unix shell (up to and including the "sh" on SunOS 5.10) the "export" command does not evaluate its parameters. However since /bin/sh is claiming attempts at POSIX conformation, it should be fixed I think so your report should become a PR.

                                        Greg A. Woods; Planix, Inc.

Home | Main Index | Thread Index | Old Index