@typhlosion You're not a REAL terminal wizard until you do it in shell! :P

(just kidding of course, this is pretty sweet! 👍)

@IceWolf do you mean running it using sh, or writing a shell script to do it?

@typhlosion Shell script. How would running a C program in sh be any different than in bash? (:

@IceWolf i have no idea how ANSI escape sequences actually work, so if someone told me sh didn't properly support 24-bit color somehow, i wouldn't be surprised

@typhlosion Escape sequences are literally just strings of characters you print to stdout. It's the terminal that matters, you can do them from any language at all. :3

@typhlosion Basically all that's special about them is the terminal sees it, goes "oh, it's an escape sequence", and does things.

@IceWolf i kind of feel like you're talking down to me and i dont really appreciate it

@typhlosion Huh? Oh, that wasn't my intention at all! I'm so sorry. ):

@typhlosion Thanks for being so upfront about it and letting me know. I'll do my best to not do that in the future.

Follow

@IceWolf turns out you can just printf at the command line so this isn't as much of a flex as i thought it would be

@IceWolf y'know, a boast, a showoffy move. i thought it would make me feel more like a terminal wizard! but it's basically just a condensed, somewhat worse version of the C code haha

@typhlosion Ah! Haha, yeah, I was completely kidding on that. C is more impressive in the first place. Shell is handy, but it's...quick and dirty. (:

@IceWolf the piece de resistance of the internals is

calc() { awk "BEGIN{ print $* }"; }

which i legit have in my .bashrc file at work, it's super useful

@typhlosion Using awk as a calculator? Huh, neat! I just use my shell, $(( )) and I can do floating-point math. Also, zcalc is really handy for when I need something more interactive. (:

@typhlosion Isn't it great? :D

Keep in mind bash only supports integer math, though.

I actually used zsh to do integration approximation (Reimann sums) in Calculus II. :P

@IceWolf ahh, see, awk has some floating point stuff too. it also has atan2 which is especially useful at work

Sign in to participate in the conversation
Awoo Space

Awoo.space is a Mastodon instance where members can rely on a team of moderators to help resolve conflict, and limits federation with other instances using a specific access list to minimize abuse.

While mature content is allowed here, we strongly believe in being able to choose to engage with content on your own terms, so please make sure to put mature and potentially sensitive content behind the CW feature with enough description that people know what it's about.

Before signing up, please read our community guidelines. While it's a very broad swath of topics it covers, please do your best! We believe that as long as you're putting forth genuine effort to limit harm you might cause – even if you haven't read the document – you'll be okay!