@kat@yarn.girlonthemoon.xyz To improve you shell programming skills, I highly recommend to check out shellcheck: https://github.com/koalaman/shellcheck It points out common errors and gives some suggestions on how to improve the code. Some details in shell scripting are very tricky to get right at first. Even after decades of shell programming, I run into “corner cases” every now and then.

E.g. in getlyr’s line 7 it warns:

echo -e $(gum style --italic --foreground "#f4b8e4" "'$artist', '$song'")
        ^-- SC2046: Quote this to prevent word splitting.

For more information:
  https://www.shellcheck.net/wiki/SC2046 -- Quote this to prevent word splitt...

Most likely not all that problematic in this application, but it’s good to know about this underlying concept. Word splitting is basically splitting tokens on whitespace, this can lead to interesting consequences as illustrated by this little code:

$ echo $(echo "Hello   World")
Hello World

$ echo "$(echo "Hello   World")" 
Hello   World

In the first case the shells sees two whitespace-separated tokens or arguments for the echo command. This basically becomes echo Hello World. So, echo joins them by a single space. In the second one it sees one argument for the echo command, so echo simply echos this single argument that contains three spaces.

⤋ Read More

Participate

Login to join in on this yarn.