Sign in to follow this  
Followers 0
SigFLUP

Dear linux script writer

10 posts in this topic

Dear linux script writer,

Unless your script needs it don't start with #!/bin/bash . Not every unix has bash by default (for example, openbsd). Want you want to start with is #!/bin/sh

Thank you for your time and consideration

edit: maybe that sounds a little harsh, i was a little angry when I wrote that.. still use /bin/sh mate

Edited by SigFLUP
0

Share this post


Link to post
Share on other sites

Prejudice is a bitch.

Just don't assume, get to know and then be an ass.

0

Share this post


Link to post
Share on other sites

You probably shouldn't use use the direct path to the interpreter and should use environment since many of the BSDs and UNIXs install stuff in different places than linux.

1

Share this post


Link to post
Share on other sites

You probably shouldn't use use the direct path to the interpreter and should use environment since many of the BSDs and UNIXs install stuff in different places than linux.

I'm not entirely sure if you can use environment variables in the interpreter line. I'm pretty sure you can't. If you have file u containing

#!$UU

echo "hello"

and we

$ export UU=/bin/sh

$ ./u

we get

/bin/ksh: ./u: No such file or directory

so it looks like we have to specify a direct path. I've seen no interpreter scripts without a direct path in the interpreter line, myself

does anyone know if having /bin/sh is posix?

Edited by SigFLUP
0

Share this post


Link to post
Share on other sites

no, I mean actually using the environment binary. #!/usr/bin/env sh, bash, ruby, python, perl, php, etc.

1

Share this post


Link to post
Share on other sites

no, I mean actually using the environment binary. #!/usr/bin/env sh, bash, ruby, python, perl, php, etc.

oh neat, I didn't know about env. cool- thanks!

0

Share this post


Link to post
Share on other sites

env is fairly common and should exist on any modern unix like operating system as well as the old ones. It should be able to resolve the path for any of the interpreters you have installed.

0

Share this post


Link to post
Share on other sites

Who cares what's in the script as long as it runs. I've never had any problems running scripts because every operating system I've used knows how to deal with .sh extensions. Good rule of thumb: if it does what it's supposed to do, hooray; if not.. you f**ked up kid, and you better figure out how to fix it.

0

Share this post


Link to post
Share on other sites

Who cares what's in the script as long as it runs. I've never had any problems running scripts because every operating system I've used knows how to deal with .sh extensions. Good rule of thumb: if it does what it's supposed to do, hooray; if not.. you f**ked up kid, and you better figure out how to fix it.

I've had this problem in the past. Usually it's a perl script where they assume perl someplace else. Every so often it's because they assume I have bash, so then I either have to go install it for them or change their script.

0

Share this post


Link to post
Share on other sites

Who cares what's in the script as long as it runs. I've never had any problems running scripts because every operating system I've used knows how to deal with .sh extensions. Good rule of thumb: if it does what it's supposed to do, hooray; if not.. you f**ked up kid, and you better figure out how to fix it.

I've had this problem in the past. Usually it's a perl script where they assume perl someplace else. Every so often it's because they assume I have bash, so then I either have to go install it for them or change their script.

I see; sounds like a Unix-related problem. It's like when you find some code/script that's missing small amounts of syntax or declarations. Typical today though; especially if you're on the avenue of security looking for tools or exploits.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0