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: Jonathan Nieder
Subject: Re: pwd as first command changes script behavior
Date: Thu, 1 Sep 2011 16:27:14 -0500
User-agent: Mutt/1.5.21+46 (b01d63af6fea) (2011-07-01)

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]