Little Girl's Mostly Linux Blog

BeginEveryBashScript

Begin every Bash script

This page was last updated on August 19, 2013.
Make this the first line of every Bash script:
#!/bin/bash
Or make this the first line of every Bash script when you’d like to avoid the default behavior of having Bash read /etc/profile (the system-wide startup file) or ~/.bash_profile, ~/.bash_login, or ~/.profile (any of the personal initialization files):
#!/bin/bash --noprofile

These are special comment lines that are not required, but are used by convention to let the shell (the environment the terminal is running in) know which interpreter to use when running your script.

Obligatory Happy Ending

And they all lived happily ever after. The end.

2 Comments »

  1. I would say something like this is better if you’re writing just a shell script:

    #!/bin/bash –noprofile

    You don’t need all the overhead of processing the startup scripts just to fork a process that already has a PATH, HOME, etc.

    Comment by Jerry — April 3, 2010 @ 2:22 pm


RSS feed for comments on this post. TrackBack URI

Comment:

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: