Cannot jump to selected directory #3738
-
I wrote the simple file manager script:
Working great, except cd to selected directory. Nothing happens when I select directory. What is wrong? |
Beta Was this translation helpful? Give feedback.
Answered by
LangLangBart
Apr 18, 2024
Replies: 2 comments
-
When you execute your program, it runs in a subshell; thus, directory changes won't affect the parent shell from which you called your script. However, you can source path/to/your/script Afterward, call the function. This method executes the script in the current shell, not a new one1. Footnotes |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
og900aero
-
Thx. Working now. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When you execute your program, it runs in a subshell; thus, directory changes won't affect the parent shell from which you called your script.
However, you can
source
it. Wrap your code in a function, then use:source path/to/your/script
Afterward, call the function. This method executes the script in the current shell, not a new one1.
Footnotes
Bash Guide for Beginners - 2.1.3. Executing the script ↩