A `cd` command in an executed Powershell script still affects the current session
Coming from the Unix world, scripts when executed (as opposed to sourced) are run in a subshell, and thus variable declarations and cd commands do not affect the actual current session (the one where we type our commands). For reference: # Executing a script ./myscript.ps1 # Sourcing a script . ./myscript.ps1 Very surprised (and quite frankly annoyed) to see than in Powershell, executing a script will still affect my current session regarding cd commands (but not declared variables). How can I prevent this from happening ?
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.