News for hackers. Stuff that matters.
Re:Build a Container Image from Scratch by ryencoke on Thursday March 20, 2025 @09:34PM (#43431016)
If you want to add in another bash trick called Parameter Expansion[0] you can parse out the filename automatically with the special variable $_. Something like:

  > wget https://dl-cdn.alpinelinux.org/alpine/v3.18/releases/x86_64/alpine-minirootfs-3.18.4-x86_64.tar.gz && tar xzf ${_##*/}
[0] https://www.gnu.org/software/bash/manual/html_node/Shell-Par...
Re:Build a Container Image from Scratch by MyOutfitIsVague on Thursday March 20, 2025 @10:17PM (#43431195)
I want to make a small note, in that `$_` is a special Bashism (though it is supported widely), but Parameter Expansion is POSIX-standard and will work on all POSIX-compliant shells, not just Bash.

https://pubs.opengroup.org/onlinepubs/009604499/utilities/xc...

Re:Build a Container Image from Scratch by vendiddy on Friday March 21, 2025 @03:43AM (#43432806)
You know I just realized after all these years I still don't quite know what a shell is.

You have iTerm, Terminal, etc. But what do those do? Those are not the shells themselves right?

Re:Build a Container Image from Scratch by kritr on Friday March 21, 2025 @04:12AM (#43432995)
iTerm and Terminal are pieces of software emulate a physical terminal environment. They take the output of programs/shells output characters and control codes to render text, clear the screen, etc.

The terminal emulator receives keyboard input via your operating system, and passes it to the shell program via stdin.

The shell is responsible for prompting you and handling whatever you type. For example the “$ “ waits for next character from the terminal emulator until you hit newline.

The shell is responsible for parsing your input, executing any child programs “ls” for example, outputting their content to stdout, and prompting you again.

Re:Build a Container Image from Scratch by mdaniel on Friday March 21, 2025 @12:28PM (#43437662)
I wanted to offer that (if you are "C handy") writing your own shell is a super informative exercise. We had to write our own shell in my operating system class at GT and I actually got it working well enough that I could "exec ./myshell" and use it for some day to day stuff. I felt empowered

I tried to dig up the course but naturally things are wwaaaaaaay different now than back in my day. But OCW has something similar https://ocw.mit.edu/courses/6-828-operating-system-engineeri... and does ship the source files https://ocw.mit.edu/courses/6-828-operating-system-engineeri... although I have no idea why that's only present in a graduate level class

Re:Build a Container Image from Scratch by godelski on Thursday March 20, 2025 @11:07PM (#43431448)
##*/ is probably one of my most used parameter expansions. This was definitely a better solution than the one I proposed lol