Question

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)

Was it helpful?

Solution

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 sourced.

OTHER TIPS

what about

if [ yourbreakcondition ]; then
    ...
else
   ...
   The rest of bashrc here
   ...
fi

Just call return within your bashrc.

Example

if [ true ]
then
    return
fi
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top