bash postinstall script returns an error

Eric Blake
Fri Aug 13 16:15:00 GMT 2010

On 08/12/2010 06:14 PM, wrote:
> I was going to mention, but I see there's already a thread
> for that, so I'll move right on to the next one.
> When I run setup.exe I always get an error for the postinstall
> script, it seems to be on the line of:
> /bin/test -e /dev/stdin  || ln -s /proc/self/fd/0 /dev/stdin  || result=1
> I'm not so clear as to why this fails. test returns a status of 1 when
> the script is run by the installer, and yet /dev/stdin does exist.
> setup.log.full contains a predictable "ln: creating symbolic link
> `/dev/stdin': File exists".

Aha.  I finally figured out why.

The postinstall script is run with stdin closed, but when you run it by
hand, unless you did the redirection <&-, you run with stdin open.

test -e /dev/stdin fails if it is a dangling symlink (which it is when
stdin is closed), which then tries the ln but that fails because the
dangling symlink is in the way.

I should really be using test -h.

$ test -e /dev/stdin; echo $?
$ test -e /dev/stdin <&-; echo $?
$ test -h /dev/stdin; echo $?
$ test -h /dev/stdin <&-; echo $?

Thanks for insisting that I fix this.

Eric Blake    +1-801-349-2682
Libvirt virtualization library

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <>

More information about the Cygwin mailing list