public inbox for linux-newbie@vger.kernel.org
 help / color / mirror / Atom feed
* Adding to the PATH but not if already in $PATH
@ 2005-02-26 18:17 Dog Walker
  2005-02-26 19:05 ` Eric Bambach
  0 siblings, 1 reply; 6+ messages in thread
From: Dog Walker @ 2005-02-26 18:17 UTC (permalink / raw)
  To: linux-newbie

I want to prepend a directory to my PATH in my $HOME/.bashrc and export the 
result. But I only want it to happen once: iow, if a directory I want 
prepended is already in the PATH, do not prepend it again.

Something like:

   if "/home/dw/bin" not in $PATH ; then
   PATH=/home/dw:$PATH
   export PATH
   fi

The questions are: Is this the way one guards against multiple additions in 
subshells? Is there a way to check for a substring?

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 6+ messages in thread
* Adding to the PATH but not if already in $PATH
@ 2005-02-26 18:16 Dog Walker
  2005-02-26 22:44 ` chuck gelm
  0 siblings, 1 reply; 6+ messages in thread
From: Dog Walker @ 2005-02-26 18:16 UTC (permalink / raw)
  To: linux-newbie

I want to prepend a directory to my PATH in my $HOME/.bashrc and export the 
result. But I only want it to happen once: iow, if a directory I want 
prepended is already in the PATH, do not prepend it again.

Something like:

   if "/home/dw/bin" not in $PATH ; then
   PATH=/home/dw:$PATH
   export PATH
   fi

The questions are: Is this the way one guards against multiple additions in 
subshells? Is there a way to check for a substring?

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

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

end of thread, other threads:[~2005-02-26 22:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-02-26 18:17 Adding to the PATH but not if already in $PATH Dog Walker
2005-02-26 19:05 ` Eric Bambach
2005-02-26 19:40   ` DogWalker
2005-02-26 20:34     ` Eric Bambach
  -- strict thread matches above, loose matches on Subject: below --
2005-02-26 18:16 Dog Walker
2005-02-26 22:44 ` chuck gelm

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