user1836155
user1836155

Reputation: 918

Change directory through bash script without messing up $PATH

Yes, I know that I can run

. my_cd_script.sh

to change my directory directly. However, once I do that, my $PATH is messed up. For instance, when I type ls, the shell will return Command not found.

Anyone encountered this?

Upvotes: 1

Views: 254

Answers (1)

Armali
Armali

Reputation: 19395

I named a variable "path" without a second thought, although I would've expected shell to be case sensitive. – user1836155

If you're running into variable names not seeming to be case-sensitive, then I suspect you're not actually using bash. Maybe csh instead, or some other variant in the csh family... – twalberg

I used the "#!/bin/bash" header though – user1836155

The header means nothing when you source a file with . myscript - it's just a comment in that case. – twalberg

Upvotes: 2

Related Questions