top | item 45958379

(no title)

jdc0589 | 3 months ago

im not saying OP did this, but I've actually had AI spit out some pretty stellar bash scripts, surprisingly

discuss

order

rkozik1989|3 months ago

I don't think its that surprising. Bash is old as dirt and scripts by definition are meant to be simple. Where AI struggles is when you add complexity like object-oriented design. That's when the effect of it trying to solve every problem in a way unique to it just takes shit off the rails. LLMs known design patterns exist but they don't know how to use them because that's not how deep learning approaches problem solving.

anandchowdhary|3 months ago

No, you're right. It was a pretty collaborative effort with me and Claude!

svieira|3 months ago

FYI, you're missing two patterns that allow the `--key=value` admirers and the `-alltheshortopsinasinglestring` spacebar savers among us to be happy (for the otherwise excellent options parsing code).

   shopt -s extglob
   case "$1"
     # Flag support - allow -xyz z-takes-params
     -@(a|b|c)*) _flag=${1:1:1}; _rest=${1:2}; shift; set -- "-$_flag" "-$_rest" "$@";;
     # Param=Value support
     -?(-)*=*) _key=${1%%=*}; _value=${1#*=}; shift; set -- "${_key}" "$_value" "$@";;
   esac

cortesoft|3 months ago

The emojis give it away