Append to PATH in smart way.

Login or Register for Dates, Times and to Reply

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Append to PATH in smart way.
# 1  
Append to PATH in smart way.

The most common problem append to $PATH-like environment variables is:

export PATH=$PATH:/new/path/to/bin

The problem is if the PATH is empty you end up with:


Is there any smarter way then checking if $PATH is empty to prevent this additional colon? Something like Bash fancy substitions?
# 2  

The leading : is harmless enough.


# 3  
Thanks. The problem is gcc fails to compile when : is in the LIBRARY_PATH and I reley heavily on automatic compilation tools.
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #425
Difficulty: Medium
C# 1.0 was first released in December 2002.
True or False?

4 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Command to see the logical volume path, device mapper path and its corresponding dm device path

Currently I am using this laborious command lvdisplay | awk '/LV Path/ {p=$3} /LV Name/ {n=$3} /VG Name/ {v=$3} /Block device/ {d=$3; sub(".*:", "/dev/dm-", d); printf "%s\t%s\t%s\n", p, "/dev/mapper/"v"-"n, d}' Would like to know if there is any shorter method to get this mapping of... (2 Replies)
Discussion started by: royalibrahim
2 Replies

2. UNIX for Dummies Questions & Answers

Explain the difference between the commands cd ~smart and cd ~/smart

Is it possible for both commands to work? (1 Reply)
Discussion started by: phunkypants
1 Replies

3. Shell Programming and Scripting

smart script?

First, I know that's a bad title. I couldn't think of anything short enough. ... I wrote the following script to let me know when various parts of the network are down. It used to look like this before last weekend when I got over 500 emails about 1 host being down all weekend: this is in the... (1 Reply)
Discussion started by: raidzero
1 Replies

4. UNIX for Advanced & Expert Users

smart question

eg. : there is a file - 322 bytes, how can I (or you) view just a half of file (161 bytes)? (3 Replies)
Discussion started by: zylwyz
3 Replies

Featured Tech Videos