LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-10-2019, 09:11 PM   #16
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869

On some platforms bash is not part of the default installation. (Aix is an example. It has ksh, awk and Perl.)
 
1 members found this post helpful.
Old 09-11-2019, 12:28 PM   #17
YesItsMe
Member
 
Registered: Oct 2014
Posts: 915

Rep: Reputation: 313Reputation: 313Reputation: 313Reputation: 313
No shell which is not bash is bash-compatible.
 
Old 09-12-2019, 12:09 AM   #18
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by boughtonp View Post
Are there any systems where #!/bin/bash (as opposed to #!/bin/sh) will execute a shell that is not Bash-compatible?
Not to my knowledge.
The instruction the hashbang gives is clear.
However, somebody (idiotic) could have symlinked another shell to /bin/bash...
 
Old 09-12-2019, 03:09 AM   #19
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
Quote:
Originally Posted by ondoho View Post

However, somebody (idiotic) could have symlinked another shell to /bin/bash...
It's not uncommon
Code:
# ls -l /bin/sh  
lrwxrwxrwx 1 root root 4 Aug 28 11:54 /bin/sh -> bash
but bash is not sh compatible in my experience, on other systems
 
Old 09-12-2019, 02:04 PM   #20
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by bigearsbilly View Post
It's not uncommon
Code:
# ls -l /bin/sh  
lrwxrwxrwx 1 root root 4 Aug 28 11:54 /bin/sh -> bash
but bash is not sh compatible in my experience, on other systems
nono, this is normal. I meant the other way round, e.g.:
Code:
# ls -l /bin/bash  
lrwxrwxrwx 1 root root 4 Aug 28 11:54 /bin/bash -> dash
That would be truly idiotic IMHO. Never seen that though.
 
Old 09-12-2019, 02:39 PM   #21
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,800

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Quote:
Originally Posted by MadeInGermany View Post
How compatible is python 3 with python 2? One day you will be confronted with python 4 versus python 3.
The Python 2<==>Python 3 differences aren't earth-shattering but are annoying. Fixing "print" statements is pretty easy. The integer math changes were a bit sticker. There are likely other, more subtle, differences that I'm not yet aware of. I've drawn a line in the sand and made a decision to do everything as Python 3 as I'm still learning it -- it's soon going to be the only game in town anyway (https://www.theregister.co.uk/2019/0...python_2_2020/) -- and I can easily make the decision to avoid Python 2.x-isms. Unfortunately, I'm sure I'll have to bone up on those, though, as I encounter older Python scripts at work. (And have to modify those to remain supported.)

I haven't run into any problems with bash syntactical changes over the years. One can easily imagine the great gnashing of teeth that would result from such a move. (No... I don't think that backticks vs. "$( )" counts as a syntax change.)

Cheers...
 
Old 09-12-2019, 05:14 PM   #22
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,599

Rep: Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546
Quote:
Originally Posted by NevemTeve View Post
On some platforms bash is not part of the default installation. (Aix is an example. It has ksh, awk and Perl.)
I'm less bothered about what's available by default, (Bash for Aix is available at http://www.perzl.org/aix/index.php?n=Main.Bash), ondoho has answered my question...

Quote:
Originally Posted by ondoho View Post
...the other way round, e.g.:
Code:
# ls -l /bin/bash  
lrwxrwxrwx 1 root root 4 Aug 28 11:54 /bin/bash -> dash
That would be truly idiotic IMHO. Never seen that though.
Yeah, that's what I was asking about - to confirm that using Bash-specific features in a #!/bin/bash script is safe (barring deliberate idiocy/sabotage).

If the script doesn't run and needs to be checked & re-written, that's fine - if it could silently behave differently then that would be another matter.

Last edited by boughtonp; 09-12-2019 at 05:15 PM.
 
Old 09-13-2019, 12:53 PM   #23
orbea
Senior Member
 
Registered: Feb 2015
Distribution: Slackware64-current
Posts: 1,950

Rep: Reputation: Disabled
Quote:
Originally Posted by boughtonp View Post
Yeah, that's what I was asking about - to confirm that using Bash-specific features in a #!/bin/bash script is safe (barring deliberate idiocy/sabotage).
Mostly, some features are only available in newer bash versions.
 
Old 10-18-2019, 12:54 AM   #24
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,789

Rep: Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201
#!/bin/bash
is always bash, bash-3 or bash-4 or bash-5, but always bash.
If you write and test your scripts in bash-3 you are quite safe.

But the standard shell is quite dangerous.
You can make it safer if you disable the glob expansion in command arguments and for-loop lists:
Code:
set -f
An alternative to bash is zsh.
zsh protects just substituted variables from further expansions (word splitting and glob-matching).
So $var handling is much safer than in a standard shell.
You can explicitly enforce the standard handling with ${=var}

Last edited by MadeInGermany; 10-18-2019 at 01:02 AM.
 
Old 10-18-2019, 02:40 PM   #25
YesItsMe
Member
 
Registered: Oct 2014
Posts: 915

Rep: Reputation: 313Reputation: 313Reputation: 313Reputation: 313
Quote:
Originally Posted by MadeInGermany View Post
#!/bin/bash
is always bash
Unless it is not installed at all or elsewhere.
 
  


Reply

Tags
automation, bash, deploy, python



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: OpenStack automation with cloud deployment tools LXer Syndicated Linux News 0 09-12-2014 12:14 PM
[SOLVED] redhat deployment with Altiris HP Rapid Deployment Tool lievendp Linux - Server 2 08-03-2011 03:11 AM
LXer: Python Python Python (aka Python 3) LXer Syndicated Linux News 0 08-05-2009 08:30 PM
deployment/scripting/automation kevinyeandel Linux - Server 3 02-09-2009 12:51 AM
Kickstart automation deployment help bbmak Linux - Enterprise 5 02-20-2007 02:06 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration