News for hackers. Stuff that matters.
Re:Colodebug: a simple way to improve Bash script debugging by gforce_de on Monday December 20, 2021 @03:56AM (#29622679)
I see 2 problems here:

major: it does not work on POSIX shells, because ':' is not a valid function name and

minor: the function itself should be changed to use the builtin 'case' instead of the bashims [[ ... ]]

Re:Colodebug: a simple way to improve Bash script debugging by c0l0 on Monday December 20, 2021 @04:46AM (#29622934)
Hey, thanks for taking the time to read and commenting! :)

Problem #1 (at least for the "advanced" part of the article's suggestion) is unfixable unless you boil the ocean and change the POSIX spec. I tried to make that clear in the prose, but might have failed at it. It's also the reason why I chose the title to refer to `bash` scripts in particular.

Problem #2 becomes less relevant once you realize that problem #1 completely overshadows it. And in `zsh`, where you can also redefine `:` to invoke a custom function, tests via `[[` also work just like they do in bash.

Re:Colodebug: a simple way to improve Bash script debugging by gforce_de on Monday December 20, 2021 @04:55AM (#29622979)
what seems possible is:

  #!/bin/sh
  
  alias :=mydebug
  mydebug() { printf '%s\n' "$\*"; }
  
  foo=1
  : this is a debugable comment
  bar=2
Re:Colodebug: a simple way to improve Bash script debugging by c0l0 on Monday December 20, 2021 @05:07AM (#29623041)
Interesting find! Apparently, also in POSIX sh programming, all problems can be overcome by introducing another layer of indirection ;)

Would it be OK for you if I added that information/workaround to the article (crediting you, of course)?

Re:Colodebug: a simple way to improve Bash script debugging by gforce_de on Monday December 20, 2021 @06:10AM (#29623510)
no problem, just do it 8-)
Re:Colodebug: a simple way to improve Bash script debugging by jbbarth on Wednesday December 22, 2021 @02:33PM (#29653939)
How is the POSIX non compliance a major problem? Does it have practical impacts when writing scripts that are not meant to be portable to other systems/shells?
Re:Colodebug: a simple way to improve Bash script debugging by gforce_de on Tuesday January 04, 2022 @12:32AM (#29791764)

  "Stick to portable constructs where possible, and
   you will make somebody's life easier in the future.
   Maybe your own."