[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: pwd as first command changes script behavior
From: |
Quiring, Sam |
Subject: |
RE: pwd as first command changes script behavior |
Date: |
Thu, 1 Sep 2011 21:47:57 +0000 |
Hi Jonathan,
Thanks for taking the time. I get it now. I am sorry to have bothered you
-Sam
-----Original Message-----
From: Jonathan Nieder [mailto:address@hidden
Sent: Thursday, September 01, 2011 2:27 PM
To: Quiring, Sam
Cc: address@hidden; address@hidden
Subject: Re: pwd as first command changes script behavior
Hi Sam,
Quiring, Sam wrote:
> #! /bin/bash
> pwd
> echo $_
>
> #! /bin/bash
> echo $_
> pwd
>
> The first one displays:
> /home/windriver/changes/NexS-235r1/with-camera
> pwd
>
> The second one displays:
> ./apply.sh
> /home/windriver/changes/NexS-235r1/with-camera
That's what $_ is advertised to do: it expands to the last
argument to the previous command, after expansion (or the full
pathname to the shell or shell script if there was no previous
command). You're probably looking for $(which $0) or something
similar.
Hope that helps,
Jonathan