Execute a command in new interactive tcsh shell

0

How can I execute a pre-command in a new tcsh interactive shell?

Ex: For mimicking bash -O globstar in tcsh we can do set globstar.

However, I need to start a new tcsh shell with 'set globstar' without depending on / changing the user's rcfile.

tcsh -c 'set globstar won't work as it won't leave the interactive shell. Exits immediately after executing the command.

Krishna

Posted 2018-09-22T06:05:08.153

Reputation: 124

Answers

0

Bash understands --rcfile, which allows you to source alternative .bashrc, but I haven't found similar option for tcsh.

Without it, I managed to achieve what you want by modifying this answer of mine. It uses expect. The script is:

#!/usr/bin/expect 

log_user 0
spawn /bin/tcsh
send "set globstar\n"
interact

Adjust paths if needed. Save the code in a file, make the file executable, then run it.

Kamil Maciorowski

Posted 2018-09-22T06:05:08.153

Reputation: 38 429

I was wondering if tcsh has some sort of inbuilt support for it. Thank you for pointing out expect @kamil-maciorowski. – Krishna – 2018-09-23T05:38:33.667