public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-user] OT:  Bash question
@ 2007-09-20  8:47 Anthony E. Caudel
  2007-09-20  9:05 ` Dirk Heinrichs
  2007-09-20 15:31 ` Frank Gruellich
  0 siblings, 2 replies; 4+ messages in thread
From: Anthony E. Caudel @ 2007-09-20  8:47 UTC (permalink / raw
  To: Gentoo Mailing List

Is there any way to make "pushd" and "popd" (Bash built-ins) silent?  As
it is, when the execute, the directory is echoed to the output, making
it difficult to use the commands in a script.  For example:

OLD_VER=$(pushd /boot; ls kernel-* | sort | head -1; popd)
echo $OLD_VER
/boot ~ kernel-2.6.22-gentoo-r2 ~

The /boot and the tildes are returned by pushd and popd and mess up the
script.

There doesn't seem to be any options to turn off the echo off and shopt
has nothing in it.

Tony

-- 
Those who would give up essential Liberty, to purchase a little temporary Safety, deserve neither Liberty nor Safety.
   -- Benjamin Franklin

-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [gentoo-user] OT:  Bash question
  2007-09-20  8:47 [gentoo-user] OT: Bash question Anthony E. Caudel
@ 2007-09-20  9:05 ` Dirk Heinrichs
  2007-09-20 15:31 ` Frank Gruellich
  1 sibling, 0 replies; 4+ messages in thread
From: Dirk Heinrichs @ 2007-09-20  9:05 UTC (permalink / raw
  To: gentoo-user

[-- Attachment #1: Type: text/plain, Size: 715 bytes --]

Am Donnerstag, 20. September 2007 schrieb ext Anthony E. Caudel:
> Is there any way to make "pushd" and "popd" (Bash built-ins) silent?  As
> it is, when the execute, the directory is echoed to the output, making
> it difficult to use the commands in a script.  For example:

You know you can always redirect output to wherever you want, even 
to /dev/null?

HTH...

	Dirk
-- 
Dirk Heinrichs          | Tel:  +49 (0)162 234 3408
Configuration Manager   | Fax:  +49 (0)211 47068 111
Capgemini Deutschland   | Mail: dirk.heinrichs@capgemini.com
Wanheimerstraße 68      | Web:  http://www.capgemini.com
D-40468 Düsseldorf      | ICQ#: 110037733
GPG Public Key C2E467BB | Keyserver: www.keyserver.net

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [gentoo-user] OT:  Bash question
  2007-09-20  8:47 [gentoo-user] OT: Bash question Anthony E. Caudel
  2007-09-20  9:05 ` Dirk Heinrichs
@ 2007-09-20 15:31 ` Frank Gruellich
  2007-09-21  8:19   ` Anthony E. Caudel
  1 sibling, 1 reply; 4+ messages in thread
From: Frank Gruellich @ 2007-09-20 15:31 UTC (permalink / raw
  To: gentoo-user

* Anthony E. Caudel <tony.caudel@sbcglobal.net> 20. Sep 07:
> Is there any way to make "pushd" and "popd" (Bash built-ins) silent?
> [snip] For example:
> 
> OLD_VER=$(pushd /boot; ls kernel-* | sort | head -1; popd)
> echo $OLD_VER
> /boot ~ kernel-2.6.22-gentoo-r2 ~

For that exact example... why you bother at all?  $( ) opens a subshell
and cd's in subshells don't interact with parent shell so you could
simply write:

 OLD_VER=$(cd /boot; ls kernel-* | sort | head -1)

or

 OLD_VER=`cd /boot; ls kernel-* | sort | head -1`

if you want to be more compatible.  Or am I missing a point?

HTH, kind regards,
 Frank.
-- 
Sigmentation fault
-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [gentoo-user] OT:  Bash question
  2007-09-20 15:31 ` Frank Gruellich
@ 2007-09-21  8:19   ` Anthony E. Caudel
  0 siblings, 0 replies; 4+ messages in thread
From: Anthony E. Caudel @ 2007-09-21  8:19 UTC (permalink / raw
  To: gentoo-user

Frank Gruellich wrote:
> * Anthony E. Caudel <tony.caudel@sbcglobal.net> 20. Sep 07:
>   
>> Is there any way to make "pushd" and "popd" (Bash built-ins) silent?
>> [snip] For example:
>>
>> OLD_VER=$(pushd /boot; ls kernel-* | sort | head -1; popd)
>> echo $OLD_VER
>> /boot ~ kernel-2.6.22-gentoo-r2 ~
>>     
>
> For that exact example... why you bother at all?  $( ) opens a subshell
> and cd's in subshells don't interact with parent shell so you could
> simply write:
>
>  OLD_VER=$(cd /boot; ls kernel-* | sort | head -1)
>
> or
>
>  OLD_VER=`cd /boot; ls kernel-* | sort | head -1`
>
> if you want to be more compatible.  Or am I missing a point?
>
> HTH, kind regards,
>  Frank.
>   
Thanks, Frank.  That is the best solution.

Tony

-- 
Those who would give up essential Liberty, to purchase a little temporary Safety, deserve neither Liberty nor Safety.
   -- Benjamin Franklin

-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-09-21  8:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-20  8:47 [gentoo-user] OT: Bash question Anthony E. Caudel
2007-09-20  9:05 ` Dirk Heinrichs
2007-09-20 15:31 ` Frank Gruellich
2007-09-21  8:19   ` Anthony E. Caudel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox