I feel like I’ve been severely underutilizing shell scripting. I first felt this way when I started using plan9 and discovering its shell named rc and how acme leverages shell commands for its scripting. Then more recently as I wanted to build a photo gallery html page generator, I kept thinking about what language to use to generate it thinking about node or go even be brutalist and doing it in C until @neauoire shared his generator that was entirely just written with a bunch of shell commands and it really hammered it in my head how much power can be had with just some basic shell scripts leveraging the existing power of your computer and OS. truly, the unix way.
=> More informations about this toot | More toots from 256k@merveilles.town
@256k @neauoire Just remember to run shellcheck on everything. The underlying ideas of pipeline composition are great, but the actual implementation can be very fragile and result in code that will break silently.
=> More informations about this toot | More toots from csepp@merveilles.town
I don't think plan 9 has a shellcheck whatever that is :P
CC: @256k@merveilles.town @neauoire@merveilles.town
=> More informations about this toot | More toots from thedaemon@hj.9fs.net
@thedaemon @256k @neauoire Ah, no, there is no rc support in shellcheck. :neofox_laugh_sweat:
Also the system in general is fragile precisely because it relies on naive shell scripting, but that's a different story.
Try opening a file with spaces in its name in Acme if you want to have a bad time.
=> More informations about this toot | More toots from csepp@merveilles.town
@csepp @thedaemon @neauoire
that's fine by me, most of the time the code i write is code i use for myself catering to my specific needs.
robustness is a virtue for commercial/public code but for myself i don't really care.
good point though. I've also heard many a rant about bash scripting and how bad it gets as soon as you start to scale things up a bit so i was saying that original post with that thought in the back of my head 🙂
depending on your views, my next toot might either reassure you or enrage you even more
((spoiler, it's about using emacs and lisp))
EDIT:
Who writes file names with spaces?!!? this isn't windows :D
=> More informations about this toot | More toots from 256k@merveilles.town
Acme's not a shell script -- and rc is just fine manipulating files with spaces; it never re-expands variables, so you don't have the traditional unix shell problems.
% awk 'BEGIN{print length(ARGV); }' $var
3
Conclusion: The shell is fine, acme fails at handling filenames with spaces.
CC: @thedaemon@hj.9fs.net @256k@merveilles.town @neauoire@merveilles.town
=> More informations about this toot | More toots from ori@hj.9fs.net
@ori @thedaemon @256k @neauoire It's not a shell script, but it uses the same data paradigm of splitting text on newlines and spaces without any way to quote the separators. rc is indeed better at variables than sh, but it still has $ifs. I remember having to muck with temporary ifs modifications a lot for some of my scripts. Couldn't just set it for the whole script of course, because then other scripts I was calling would misbehave. I also remember other tools messing up when the path had unexpected characters, but it's been a while, so maybe they have been fixed. Oh, wait, no, that one was about passing unsanitized input to sed.
These frustrations were the reason I created a linear TSV parsing library in KenC. If/when I give 9front another try, I'll probably get back to that and writing quote/unquote utilities for the various DSLs involved in coreutils. (certainly rc, sed, and grep)
=> More informations about this toot | More toots from csepp@merveilles.town
You don't need to modify IFS temporarily -- we have a syntax for splitting at the right place:
'
lines = `$nl{cmd}
And, yes, this is the one and only time that rc will split words. That said, it'd be interesting to have rc directly handle quoted output in the format of quotefmtinstall. Maybe ``{...}:
CC: @thedaemon@hj.9fs.net @256k@merveilles.town @neauoire@merveilles.town
=> More informations about this toot | More toots from ori@hj.9fs.net
@ori Thanks, I wasn't aware of that feature at the time.
@thedaemon @256k @neauoire
=> More informations about this toot | More toots from csepp@merveilles.town This content has been proxied by September (3851b).Proxy Information
text/gemini