lens0021

joined 2 months ago
[–] lens0021@programming.dev 1 points 5 days ago

Thank you for this comment. I'm revisiting this comment because I need to write this...

collapsed inline mediaComparing strings in a github actions workflow

[–] lens0021@programming.dev 1 points 6 days ago* (last edited 6 days ago) (1 children)

Fish is my main shell of choice and I use my self-written functions(https://github.com/lens0021/Lens0021_Personal.Fish/blob/main/conf.d/lens0021_personal.fish) daily. But it is hard for me to say Fish's syntax is not weird. Especially, I'm a little fuzzy on how to use argparse. I am sorry.

[–] lens0021@programming.dev 3 points 6 days ago* (last edited 6 days ago)

Currently, Amber does not even support Bash 2 because Bash 2 does not support the += operator. (ticket) However, I believe that POSIX compliance is on Amber's long-term milestone, and that it will eventually achieve this as its support range expands.

[–] lens0021@programming.dev 3 points 6 days ago (1 children)

tbh, I wouldn't recommend that during alpha staging. There are still many bugs.

[–] lens0021@programming.dev 3 points 6 days ago (1 children)

Yep, the code you provided is compiled into this:

command_0="$(cat file.txt | grep "READY")"
__status=$?
if [ "${__status}" != 0 ]; then
    echo "Failed to read the file"
fi

So, the outcome would depend on the pipefail option. (set -o pipefail)

As you suggested, an Amberic snippet would be:

import { file_read } from "std/fs"
import { match_regex } from "std/text"

const result = file_read("file.txt") failed {
    echo "Failed to read the file"
}
if match_regex(result, "READY"):
    echo "file.txt contains READY"
 

My primary use case for Amber is when I need to write a Bash script but don't remember the silly syntax. My most recent Bash mistake was misusing test -n and test -z. In Amber, I can just use something == "" or len(something) == 0