bug-bash
[Top][All Lists]
Advanced

[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:jrnieder@gmail.com] 
Sent: Thursday, September 01, 2011 2:27 PM
To: Quiring, Sam
Cc: bug-bash@gnu.org; bash@packages.debian.org
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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]