jacobdeichert/mask

"cd" command does not work in mask

zen opened this issue · 3 comments

zen commented

Hi there, great tool.

I have a very weird issue with mask. I defined really simple maskfile:

# Common Tasks
easy tedious task management

## go
> go to common folders

### go work 
> go to work folder

~~~sh
echo "changing dir..."
cd $HOME/projects/work
~~~

after launching `mask go work` I'm still in current folder. I tried changing interpreter (sh, bash, zsh), interpolation, removing variables at all with no avail. I guess that must be something trivial I'm missing.

Mac OS X 11.2.3
zsh 5.8 (x86_64-apple-darwin20.0)
mask 0.10.0
zen commented

All right, now I understand after tracing the entire execution. So actually mask cannot be used for such pattern, it spawns new shell process, executes commands and closes, so you would and up in the calling shell process and original dir.

Hey, thanks for checking out mask!

You're right, that's not how mask works. Mask runs the task/script within a subprocess it spawns instead of operating within the current process/shell.

If you want to get a bit creative, you could make a mask cmd that echos some bash aliases/variables/helpers and you could possibly source those into your current shell process.

Going to close this as it's not a bug 👍