bash - Ubuntu script language doesn't work as expect -


this question has answer here:

as beginner of bash script, wrote simple script change directory. here source code:

#!/bin/bash  set -x echo "---------------------start-----------" cd /home/cocadas/workspace/carnd/carnd-behavioral-cloning-p3 

i save "start" in /root folder. change property of file executable, , run below. problem execution command cd doesn't work. did miss?

cocadas@cocadas-thinkpad-w540:~$ ./start + echo ---------------------start----------- ---------------------start----------- + cd /home/cocadas/workspace/carnd/carnd-behavioral-cloning-p3 cocadas@cocadas-thinkpad-w540:~$ cd /home/cocadas/workspace/carnd/carnd-behavioral-cloning-p3 cocadas@cocadas-thinkpad-w540:~/workspace/carnd/carnd-behavioral-cloning-p3$ 

your ./start call creates sub shell. run source start or . start (. abbreviation of source) instead execute script directly in command line, not in nested container.


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -