You can use the return
command to "exit" your script. It's usually an error to use return
outside of a function, but you can think of the entire script as a function if it is being source
d.
Abort from a .bashrc script
-
28-06-2022 - |
Domanda
I know the .bashrc
script must be run like source .bashrc
or . .bashrc
so changes in exports are kept during the session, but i need to abort from half the bashrc script without exiting the session.
Currently i'm doing a binary search of a point where i issue a command which assumes the existence of a tty. This is to avoid getting the message stdin: is not a tty
. So the easiest way is to break the execution of the bashrc script, but i haven't found a way to do so.
How do i abort from half the execution inside the .bashrc script w/o ending the session? (aka using the exit command)
Soluzione
Altri suggerimenti
what about
if [ yourbreakcondition ]; then
...
else
...
The rest of bashrc here
...
fi
Just call return within your bashrc.
Example
if [ true ]
then
return
fi
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow