Search code examples
unixcshcd

Run cd in script and stay in that directory - 'source' command not helping


Tried using the answer found here:

How to run 'cd' in shell script and stay there after script finishes?

When I add the 'source' command, the directory is still unchanged after script runs, regardless of whether I execute 'source ' or call the script using an alias coded in cshrc.

Any help is much appreciated!


Solution

  • It was necessary to remove "/bin/" from the cd command within this script, in order for the command to work as intended. Removing this removes the subshell issue for this script. Also, coding "$1" in the ls command was invalid in this context.