I have a shell script that starts with:
sdir=`dirname $0`
sdir=`(cd "$sdir/"; pwd)`
And it usually expands (with 'sh -h') in
++ dirname /opt/foo/bin/bar
+ sdir=/opt/foo/bin
++ cd /opt/foo/bin/
++ pwd
+ sdir=/opt/foo/bin
but for one user for one combination of parameters in the extension (note the two lines in the value of the sbin result)
++ dirname bin/foo
+ sdir=bin
++ cd bin/
++ pwd
+ sdir='/opt/foo/bin
/opt/foo/bin'
I tried different combinations, but could not reproduce this behavior. With different input parameters for this user, he began to produce the correct result of one line. I am new to shell scripts, so please advise when (cd X; pwd)can return two lines. this has been observed on CentOS, but not sure if it matters. Please advice.
pepperson
source
share