Questions tagged [source-command]
6 questions
13
votes
3 answers
How can I skip the rest of a script without exiting the invoking shell, when sourcing the script?
I have a bash script, where I call exit somewhere to skip the rest of the script when getopts doesn't recognize an option or doesn't find an expected option argument.
while getopts ":t:" opt; do
case $opt in
t)
…
Tim
- 98,580
- 191
- 570
- 977
6
votes
3 answers
Parameters passed to a sourced script are wrong
A script on AIX which checks the number of parameters passed and complains if they are not correct:-
if [ "$#" -ge 1 ]; then
...
else
echo 'Usage: myscript [b] [c]'
fi
The script sets some environment variables so it is sourced. By that I…
Morag Hughson
- 171
- 1
- 6
1
vote
1 answer
/bin/ksh: bad interpreter: No such file or directory
I have script with #!/bin/ksh in the first line.
When I try to execute this script (run ./myscript.sh) the error occurred:
-bash: ./myscript.sh: /bin/ksh: bad interpreter: No such file or directory
But when I execute this script through source…
Nik
- 13
- 1
- 1
- 3
1
vote
2 answers
Why does the command 'source' have that name?
I wonder why a command that executes commands from a file in the current shell is named source. I can't see a relation between run commands in the current shell and the meaning of the english word source. Is there a history behind that name?
rrd
- 145
- 4
1
vote
2 answers
How to decrypt the file on the fly without process substitution?
I need to source the file by decrypting it on the fly using the below command.
. <(gpg -qd "$encrypted_filename")
sh is not supporting process substitution. I can't use bash. Please suggest some other way.
Is there a way to source an encrypted…
aravindderajan
- 11
- 3
-1
votes
1 answer
Can a bash script add to the context of zsh?
I have recently migrated from bash to zsh.
I used to use the following token_refresh.sh script to ssh-add my private key to the session:
#!/usr/bin/env bash
echo "configuring ssh access.."
eval "$(ssh-agent -s)"
ssh-add ./my-key
However, I can't…
StuperUser
- 123
- 6