bash postinstall script returns an error

Eric Blake eblake@redhat.com
Fri Aug 13 16:15:00 GMT 2010


On 08/12/2010 06:14 PM, cy.20.superconductor@xoxy.net wrote:
> I was going to mention passwd-grp.sh, 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 bash.sh 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 $?
0
$ test -e /dev/stdin <&-; echo $?
1
$ test -h /dev/stdin; echo $?
0
$ test -h /dev/stdin <&-; echo $?
0

Thanks for insisting that I fix this.

-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://cygwin.com/pipermail/cygwin/attachments/20100813/b0693731/attachment.sig>


More information about the Cygwin mailing list