Announcement

Collapse
No announcement yet.

GNU Bash 5.1 Released With New "SRANDOM" Variable As A New Means Of Randomness

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • skeevy420
    replied
    Originally posted by Alexmitter View Post

    I do not hate myself enough to write pure POSIX shell scripts. My scripts are written with all bashisms I need to get the job done in a reasonable fashion and are expected to be executed in bash by the end user.

    Its my main programming language after all, so I write a lot of lines of bash per month.
    I used to be a POSIX/sh defender, especially in regards to OS scripts, but at some point it's like saying I'm not going to use Python because it might not be installed on someone's PC or some Python person saying I'm not gonna use Pip because someone might not have the internet available.

    So now I use Zsh and Bash isms and I don't care about maintaining compat with sh. #!/bin/not-sh ain't that hard to figure out

    Leave a comment:


  • sdack
    replied
    Anyone who is having difficulties compiling bash-5.1 because of a seemingly missing include file "builtext.h" try compiling it without parallelisation (i.e. make -j1). There is evidently a dependency missing and causing the build to randomly fail.

    Leave a comment:


  • Alexmitter
    replied
    Originally posted by dirlewanger88

    Shell scripts should be written in POSIX sh, unless there's a reason not to. bash and zsh mostly add interactive features. Even arrays seem to be coming to sh in the next POSIX spec.

    Also, there's nothing "modern" about bash (not that "modern" actually means anything these days).
    I do not hate myself enough to write pure POSIX shell scripts. My scripts are written with all bashisms I need to get the job done in a reasonable fashion and are expected to be executed in bash by the end user.

    Its my main programming language after all, so I write a lot of lines of bash per month.

    Leave a comment:


  • microcode
    replied
    Originally posted by uid313 View Post
    So now if you the SRANDOM variable then your shell scripts will only work on Bash and it will not work on other shells such as ash, dash, fish, zsh, etc.
    FWIW fish is incompatible even with most POSIX shell stuff. It's no great big deal that it doesn't yet also include this special symbol.

    Leave a comment:


  • uid313
    replied
    Originally posted by S.Pam View Post
    Is there something that would prevent those shells from also having this variable?
    No, they can also implement it, but right now it is not a standard, so it is a Bashism.

    Leave a comment:


  • jabl
    replied
    Originally posted by dirlewanger88

    Shell scripts should be written in POSIX sh, unless there's a reason not to. bash and zsh mostly add interactive features. Even arrays seem to be coming to sh in the next POSIX spec.

    Also, there's nothing "modern" about bash (not that "modern" actually means anything these days).
    Or then you just put "#!/bin/bash" in your shell script and forget about POSIX sh? Depends on what you do of course, but 99% of the shell scripts I write will never run on anything but Linux. My life is too short to worry about writing POSIXly correct sh.

    Now, what you absolutely shouldn't do, and which has caused a lot of headaches in the Linux ecosystem, is writing bash and executing it as POSIX sh. That tends to break when someone like Debian decides that /bin/sh is no longer a symlink to bash.

    Leave a comment:


  • gggeek
    replied
    Originally posted by dirlewanger88

    Shell scripts should be written in POSIX sh, unless there's a reason not to. bash and zsh mostly add interactive features. Even arrays seem to be coming to sh in the next POSIX spec.
    I used to be of the same advice, but nowadays I spend a lot more time doing shell scripting that in the past, because devops (the future is often surprising!), and I find that: 1. bash docs are ubiquitous. 'Posix sh' docs by comparison are an order of magnitude less (this includes man pages as well as blog posts, tutorials, snippets, etc). 2. usage of containers has changed a lot the way we develop: instead of coding for multi-platform we can now let the app dictate the os and provide a container to anyone running a different env. 3. there are many features besides arrays in bash that are nice enough for scripting and not only interactive usage to make me feel awkward every time I try do some 'posix sh'.

    Leave a comment:


  • S.Pam
    replied
    Originally posted by uid313 View Post
    So now if you the SRANDOM variable then your shell scripts will only work on Bash and it will not work on other shells such as ash, dash, fish, zsh, etc.
    Is there something that would prevent those shells from also having this variable?

    Does srandom have options for guaranteeing certain confidentiality of the randomness so that it won't fall back to less secure versions?

    Leave a comment:


  • Alexmitter
    replied
    Originally posted by uid313 View Post
    So now if you the SRANDOM variable then your shell scripts will only work on Bash and it will not work on other shells such as ash, dash, fish, zsh, etc.
    Yes, if you write a modern shell script, it will only work in modern shells.

    You will have to stick with pure unix shell language if you want it to run on the strange and trendy ones like zsh.

    Leave a comment:


  • uid313
    replied
    So now if you the SRANDOM variable then your shell scripts will only work on Bash and it will not work on other shells such as ash, dash, fish, zsh, etc.

    Leave a comment:

Working...
X