News for hackers. Stuff that matters.
Re:Better Adb-Shell by chasil on Monday April 15, 2024 @10:22AM (#40040890)
In startup.sh, here are a few things to think about.

Instead of setting RED/GREEN/BLUE, you could do this:

  N=$(printf \\033)
  N="$N[" x=30

  for a in Bl R G Y B M C W  # Black Red Green Yellow Blue Magenta Cyan White
  do eval $a='$N'"'"$((     x))"m'" \
         b$a='$N'"'"$((60 + x))"m'" \
      ${a}bg='$N'"'"$((10 + x))"m'" \
     b${a}bg='$N'"'"$((70 + x))"m'" # bX=bright Xbg=background bXbg=brgt bgnd
     x=$(( x + 1 ))
  done                       # https://en.wikipedia.org/wiki/ANSI_escape_code
Unless you have "set -e" this:

  if [ ! "$HOSTNAME" ]; then
    HOSTNAME="$(hostname -s)"
  fi
Is more succinctly expressed as this:

  [ -z "$HOSTNAME" ] && HOSTNAME="$(hostname -s)"
Re:Better Adb-Shell by matan-h on Monday April 15, 2024 @11:31AM (#40041905)
Apart from the length, what advantages does `[-z $VAR ] && VAR=x` over `if [ ! $VAR ]; then VAR=x fi` ?

Btw, The color script is cool. This makes ANSI sensible.

Re:Better Adb-Shell by chasil on Monday April 15, 2024 @12:14PM (#40042479)
I don't think there are any functional or performance differences between these forms:

  [ -n "$var" ] || var=X
  [ -z "$var" ] && var=X
  if [ ! "$var" ]; then var=X; fi
It's a question of [your] style and taste, I think.

There are a lot more ANSI sequences that I could work into that block, but it is quite thorough for the space it occupies.

Re:Better Adb-Shell by gizmo686 on Monday April 15, 2024 @12:07PM (#40042396)
If -e is set you can use || and invert the condition.