[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] Stupid Question on ksh script
- Subject: [ale] Stupid Question on ksh script
- From: jonathan.l.meek at gmail.com (Jonathan Meek)
- Date: Tue, 11 Mar 2014 13:42:59 -0400
Hello everyone,
I am reviewing a script at work in order to understand that someone has
done before me. They decided to ksh to write their scripting. There's an if
statement I don't quite get and would be grateful for some light on the
issue. Here's the code snippet:
if [ ${0#/} = ${0} ] ; then
X=${PWD}/${0}
else
X=${0}
fi
cd $(dirname ${X})
Based on my own searching for meaning and understanding and somewhat
limited look into the man pages for ksh(couldn't remember how to search
within vi), here's what I think is going on:
The if statement is checking what shell is currently running and as long as
it is the expected shell, it will assign X to ${PWD}/${0}. If not, it will
assign X to ${0}. Then it will change directories based on the output of
dirname, which could be the current directory or the directory that
variable X is at.
Does this sound right or I am missing something?
Regards,
Jonathan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.ale.org/pipermail/ale/attachments/20140311/a2309f14/attachment.html>