UNIX processes
Quote:
I read this in a Linux tutorial. And this lead me to think that if I created a function that changed my directory, it would execute the function and still return me to the same place before I ran the script, so I created: changeDir() { cd / } and executed it from my home directory. And the result was me getting redirected to /. Am I doing something wrong? What are they referring to if not that? I don't understand. :( I tried searching in Google but found nothing. Thank you very much in advance. |
Ok, how did you use this function you created? The tutorial mentions running in a shell script. I just tried putting this into a script called test.bash:
Code:
#!/bin/bash This is why: The '#!/bin/bash' at the top says to create a new bash shell and execute the commands within that new shell. This new shell is another process, and not at all related to the shell you started the script from. It's similar to having two terminals open at the same time. make sense? |
Oh... I got it to work. I can't figure out what I had one wrong but I created my script again and ran it and everything ran smoothly. Thanks for your help.
|
Hehehe... typing this:
Code:
. example As for the PATH environment variable, it is entirely up to you whether to include the current directory or not. I prefer not to, because then I'm guaranteed not to run something accidentally. Only the programs "officially" installed will run, forcing me to be absolutely certain I want to run what's in the current dir. |
Yeah I got aware of my stupid reply and edited it :P I didn't know about the alias, though. :) That cleared yet more doubts out. Thanks a bunch.
|
Stupid? Nah. It's those little things that can cause the biggest stumbling blocks. I chuckled only because I had very similar experiences.
Glad I could help. |
All times are GMT -5. The time now is 04:35 PM. |