Little Girl's Mostly Linux Blog

BeginEveryBashScript

Begin every Bash script

This page was last updated on April 03, 2010.

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


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

Leave a Reply

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 )

Connecting to %s

Theme: WordPress Classic. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.