As for the incident itself, at first we thought it was a standard core barrier failure. A hole opens in the Firma, and exposes the upper layers to the core. Anything within the path of the extreme...
Okay finally a BASH post that doesn’t give me mild nausea! Shellcheck has really changed my experience of BASH. I’ve always used it since beginning my programming journey, but quickly I was made...
Okay finally a BASH post that doesn’t give me mild nausea! Shellcheck has really changed my experience of BASH. I’ve always used it since beginning my programming journey, but quickly I was made aware of how brutal its footguns can be and how arcane its syntax can be. Shellcheck gives me so much peace of mind that the scripts I write likely don’t have land mines in them.
I used to avoid using BASH for anything beyond small, personal scripts, but now I’ve used it in much broader contexts including in glueing together some of my production systems at my job. BASH has its limits (although @hungariantoast seems to be on a crusade to disprove that), but it really is an indispensable tool in a programmer’s tool belt and Shellcheck feels like a nearly mandatory auxiliary to me.
After years of shell checking scripts, I almost always correctly quote variables on my own now. But it's still a very useful tool. 10/10 would install again
After years of shell checking scripts, I almost always correctly quote variables on my own now. But it's still a very useful tool. 10/10 would install again
'i almost always don't forget how to do the basics of my job' - rephrasing what you've said into my own words. I, however, regularly forget. It hurts. Love me some bash.
'i almost always don't forget how to do the basics of my job' - rephrasing what you've said into my own words. I, however, regularly forget. It hurts. Love me some bash.
The thing about bash is: it's nobody's job. It's more like if all the jobs had elevators that you had to program in order to get to your office. It's not on anybody's resume. Nobody takes a class...
The thing about bash is: it's nobody's job.
It's more like if all the jobs had elevators that you had to program in order to get to your office. It's not on anybody's resume. Nobody takes a class on it. Nobody even mentions it. But everybody has to do it.
Oh and by the way all the elevators (shells) are slightly different. So most of the time you get to your floor no matter which kind of elevator it is, but sometimes it's an unexpectedly old elevator that plummets to the basement (sh).
Scary stories to tell in the dark: "You have to fix something on this ancient and critical solaris system. There is no outside internet access. Vi is the only editor available. You don't remember...
Scary stories to tell in the dark: "You have to fix something on this ancient and critical solaris system. There is no outside internet access. Vi is the only editor available. You don't remember the escape sequence to exit it."
I know tar xzvf filename to untar tar czvf filename path/to/add to tar and zip Replace the z with a j for bzip instead of grip (obviously) I also know that if you leave the filename out of the...
I know
tar xzvf filename to untar
tar czvf filename path/to/add to tar and zip
Replace the z with a j for bzip instead of grip (obviously)
I also know that if you leave the filename out of the second command and use a wildcard in the path, you'll overwrite the first file you want to add with a tarball of the rest of them.
I feel like my other reply was laden with snark, so I also wanted to say I like your rephrasing. I work in a pretty low trust environment, or I'd happily have that on a t-shirt.
I feel like my other reply was laden with snark, so I also wanted to say I like your rephrasing. I work in a pretty low trust environment, or I'd happily have that on a t-shirt.
I love shellcheck! It's a staple in my ability to bash script. Although it did fail me, once. I was working on a multi-hundred line bash script, with some big changes that required significant...
I love shellcheck! It's a staple in my ability to bash script. Although it did fail me, once.
I was working on a multi-hundred line bash script, with some big changes that required significant edits that couldn't be tested until I had re-written many many lines. Upon running the script, I got a syntax error. But shellcheck reported no such errors. I was stumped. 15 minutes of Google and Stack Overflow later, I was led to believe that I had dropped a character relating to defining something, somewhere.
So, I wrote another bash script, find_mismatch.bash:
#!/bin/bash
# Provide an input file, get a breakdown of lines that do not have matching single ticks, square brackets, or curly brackets
n="1"
while read -r line; do
unset footer
count="0"
for (( i=0; i<${#line}; i++ )); do
if [[ "${line:${i}:1}" == "[" ]]; then
(( count++ ))
footer="${footer}${line:${i}:1}"
elif [[ "${line:${i}:1}" == "]" ]]; then
(( count++ ))
footer="${footer}${line:${i}:1}"
elif [[ "${line:${i}:1}" == "{" ]]; then
(( count++ ))
footer="${footer}${line:${i}:1}"
elif [[ "${line:${i}:1}" == "}" ]]; then
(( count++ ))
footer="${footer}${line:${i}:1}"
elif [[ "${line:${i}:1}" == "'" ]]; then
(( count++ ))
footer="${footer}${line:${i}:1}"
else
footer="${footer} "
fi
done
if [[ "${count}" -ne "0" ]]; then
if ! [[ "$((count%2))" -eq "0" ]]; then
echo "Line ${n}"
echo "${line}"
echo "${footer}"
echo ""
read -n 1 -s -r -p "Press any key to continue" </dev/tty
fi
fi
(( n++ ))
done < "${1}"
echo ""
exit 0
And set it loose on my original multi-hundred line script. Sure enough, I found an associate array variable incorrectly defined:
fileRatingKey["${fileId}"="${ratingKey}"
^
With a missing closing ] as indicated above. Surprisingly, shellcheck couldn't/wouldn't pick this up and alert me to it. But other than that one time it failed me, it's been an absolute staple for me. Extremely helpful tool.
I like it! Though it seems silly to me that you wrote the second script when you could easily have just sacrificed a goat to the gods of sed and done it in a one-liner ;) I am curious whether...
I like it! Though it seems silly to me that you wrote the second script when you could easily have just sacrificed a goat to the gods of sed and done it in a one-liner ;)
I am curious whether Claude Sonnet or ChatGPT would be able to find it. They aren't good at everything, but they seem pretty good at that kind of thing.
I find myself on Shell check more frequently than I care to admit. I love it. And I love disagreeing with its suggestions out of sheer spite. /S I had no idea I could install it too. Thanks for...
I find myself on Shell check more frequently than I care to admit. I love it.
And I love disagreeing with its suggestions out of sheer spite. /S
I had no idea I could install it too. Thanks for sharing.
As for the incident itself, at first we thought it was a standard core barrier failure. A hole opens in the Firma, and exposes the upper layers to the core. Anything within the path of the extreme heat and radiation that's unleashed, is destroyed.
We may need the tildes equivalent of r/outoftheloop :D
Okay finally a BASH post that doesn’t give me mild nausea! Shellcheck has really changed my experience of BASH. I’ve always used it since beginning my programming journey, but quickly I was made aware of how brutal its footguns can be and how arcane its syntax can be. Shellcheck gives me so much peace of mind that the scripts I write likely don’t have land mines in them.
I used to avoid using BASH for anything beyond small, personal scripts, but now I’ve used it in much broader contexts including in glueing together some of my production systems at my job. BASH has its limits (although @hungariantoast seems to be on a crusade to disprove that), but it really is an indispensable tool in a programmer’s tool belt and Shellcheck feels like a nearly mandatory auxiliary to me.
After years of shell checking scripts, I almost always correctly quote variables on my own now. But it's still a very useful tool. 10/10 would install again
'i almost always don't forget how to do the basics of my job' - rephrasing what you've said into my own words. I, however, regularly forget. It hurts. Love me some bash.
The thing about bash is: it's nobody's job.
It's more like if all the jobs had elevators that you had to program in order to get to your office. It's not on anybody's resume. Nobody takes a class on it. Nobody even mentions it. But everybody has to do it.
Oh and by the way all the elevators (shells) are slightly different. So most of the time you get to your floor no matter which kind of elevator it is, but sometimes it's an unexpectedly old elevator that plummets to the basement (sh).
Nothing like when you get stuck on the sub basement sh container with just a flashlight and a can of bug spray.
Scary stories to tell in the dark: "You have to fix something on this ancient and critical solaris system. There is no outside internet access. Vi is the only editor available. You don't remember the escape sequence to exit it."
Enter a valid tar command on your first try.
I know
tar xzvf filename
to untartar czvf filename path/to/add
to tar and zipz
with aj
for bzip instead of grip (obviously)I also know that if you leave the filename out of the second command and use a wildcard in the path, you'll overwrite the first file you want to add with a tarball of the rest of them.
Minor fun tar fact: when extracting you can leave off the compression flags, it will figure them out itself.
I feel like my other reply was laden with snark, so I also wanted to say I like your rephrasing. I work in a pretty low trust environment, or I'd happily have that on a t-shirt.
I completely picked up and enjoyed your snark!
I love shellcheck! It's a staple in my ability to bash script. Although it did fail me, once.
I was working on a multi-hundred line bash script, with some big changes that required significant edits that couldn't be tested until I had re-written many many lines. Upon running the script, I got a syntax error. But shellcheck reported no such errors. I was stumped. 15 minutes of Google and Stack Overflow later, I was led to believe that I had dropped a character relating to defining something, somewhere.
So, I wrote another bash script,
find_mismatch.bash
:And set it loose on my original multi-hundred line script. Sure enough, I found an associate array variable incorrectly defined:
With a missing closing
]
as indicated above. Surprisingly, shellcheck couldn't/wouldn't pick this up and alert me to it. But other than that one time it failed me, it's been an absolute staple for me. Extremely helpful tool.I like it! Though it seems silly to me that you wrote the second script when you could easily have just sacrificed a goat to the gods of sed and done it in a one-liner ;)
I am curious whether Claude Sonnet or ChatGPT would be able to find it. They aren't good at everything, but they seem pretty good at that kind of thing.
Trouble is, I was fresh out of goats, I just sold them all to Lumon
I think this is a Severance reference? I really need to get my alternative media sources sorted out so I can watch that.
I find myself on Shell check more frequently than I care to admit. I love it.
And I love disagreeing with its suggestions out of sheer spite. /S
I had no idea I could install it too. Thanks for sharing.