ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,800
Rep:
Quote:
Originally Posted by MadeInGermany
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.)
# 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.
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.
#!/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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.