News for hackers. Stuff that matters.
Re:Bash 5.2 by chasil on Tuesday September 27, 2022 @01:41PM (#32998555)
A few "gotchas:"

I will commonly "alias p=printf" in my shell scripts. This is fine in Almquist and bash when called as /bin/sh, but if called as /bin/bash it fails, because bash only honors aliases in POSIX mode.

In bash, reading with a prompt can be done with "read -p prompt var" but this fails in Korn because it's used for coprocesses. This means that your shell script will not run on Android, because mksh is the system shell.

I could probably think of a few more with some effort, and especially a check of the man pages.

p.s. I didn't downvote you.

Re:Bash 5.2 by joombaga on Wednesday September 28, 2022 @12:52PM (#33010185)
> bash only honors aliases in POSIX mode.

Aliases certainly _work_ in bash (even when not in POSIX mode. What do you mean by "honors"?

Re:Bash 5.2 by chasil on Wednesday September 28, 2022 @04:59PM (#33013180)
Bash will not expand aliases within a shell script unless it is in POSIX mode.

When not in POSIX mode, aliases are only expanded for interactive use.

  $ echo '#!/bin/sh \n alias p=printf \n p %s\\\\n "hello world!"' > ok.sh
  $ chmod 755 ok.sh
  $ ./ok.sh
  hello world!

  $ echo '#!/bin/bash \n alias p=printf \n p %s\\\\n "hello world!"' > nope.sh
  $ chmod 755 nope.sh
  $ ./nope.sh 
  ./nope.sh: line 3: p: command not found