this post was submitted on 02 Nov 2023
0 points (NaN% liked)

Linux

48287 readers
619 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS
 

[For reference, I'm talking about Ash in Alpine Linux here, which is part of BusyBox.]

I thought I knew the big differences, but it turns out I've had false assumptions for years. Ash does support [[ double square brackets ]] and (as best I can tell) all of Bash's logical trickery inside them. It also supports ${VARIABLE_SUBSTRINGS:5:12}` which was another surprise.

At this stage, the only things I've found that Bash can do that Ash can't are:

  • Arrays, which Bash doesn't seem to do well anyway
  • Brace expansion, which is awesome but I can live without it.

What else is there? Did Ash used to be more limited? The double square bracket thing really surprised me.

top 3 comments
sorted by: hot top controversial new old
[–] suprjami@lemmy.sdf.org 0 points 1 year ago* (last edited 1 year ago) (1 children)

What have you found bad about bash arrays? I have some simple usage of those (in bash) and they work fine.

[–] danielquinn@lemmy.ca 0 points 1 year ago (1 children)

As far as I've seen, they don't provide any advantage over a string with spaces, which doesn't work well either when you've got values with spaces:

not_what_you_think=( "a b" "c" "d" )
for sneaky in ${not_what_you_think[@]}; do
  echo "This is sneaky: ${sneaky}"
done
This is sneaky: a
This is sneaky: b
This is sneaky: c
This is sneaky: d
[–] shmanio@lemmy.world 1 points 1 year ago* (last edited 7 months ago)

You should put some quotes where you use the array:

not_what_you_think=( "a b" "c" "d" )
for sneaky in "${not_what_you_think[@]}"; do
  echo "This is sneaky: ${sneaky}"
done

This is sneaky: a b
This is sneaky: c
This is sneaky: d