This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: bash postinstall script returns an error


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

Attachment: signature.asc
Description: OpenPGP digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]