How to keep aliased commands in Command::new

Howdy,

When running Command::new() using bash -c in the args, it doesn't recognise any aliased commands in my .rc files, and putting the aliased command in the ::new call says it cannot find the file or directory.

Both of these outcomes make sense but is there any way I can execute a bash command which can use all of the variables & commands in the sourced files in my current session?

Thanks

Bash uses different configurations for interactive and non-interactive shells. You're probably defining aliases in interactive-only config file. I don't remember off hand which is which, but search in that direction.

3 Likes

Apparently if you set the env variable BASH_ENV to a filename, when launching a non-interactive shell, Bash will try to source that file like it was one of the normal startup files.

2 Likes

I've found how to do it, you can use bash -ic command to run code in an interactive terminal and this runs the .rc files

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.