Summarize the following text in less than 50 words. Let's think step by step: bash is great for automating little tasks, but sometimes a little script you think will take a minute to write turns into a half hour or more. this is the story of one of those half-hour scripts. i have too many 3d printers. in particular, i have three that are almost but not exactly the same, so each one has a slightly different build process when i want to update their firmware. in all fairness, one of those printers is heading out the door soon, but i'll probably still wind up building firmware images for it. my initial process was painful. i have a special directory with the four files needed to configure marlin for each machine. i copy all four files and ask platformio to perform the build. usually, it succeeds and gives me a file that looks like firmware-yyyyddmmhhmm.bin or something like that. the problem is that the build process doesn't know which of the three machines is the target: sulu, checkov, or fraiser. (long story.) so, i manually look at the file name, copy it, and rename it. of course, this is an error-prone process, and i'm basically lazy, so i decided to write a script to do it. i figured it would take just a minute to bundle up all the steps. i was wrong. first attempt copying the files to the right place was a piece of cake. i did check to make sure they existed. the problem came from launching platformio, seeing the result on the screen, and being able to parse the filename out of the stream. i thought it would be easy: fn=$(pio run | grep '^renamed to' | cut -d ' ' -f 3 ) that should do the build and leave $fn with the name of the file i need to rename and process. it does, but there are two problems. you can't see what's happening, and you can't tell when the build fails. easy problem first the pipeline consumes the build's output. of course, a tee command can manage that, right? well, sort of. the problem is that the tee command sends things to a file and standard out, but the standard out, in this case, is the pipe. sure, i could tee the output to a temporary file and then process that file later, but that's messy. so, i resorted to a bash-specific feature: fn=$(pio run | tee /dev/fd/2 | grep ... this puts the output on my screen but still sends it down the pipe, too. sure, there are cases when this isn't a good idea, and it isn't very portable, but for my own use, it works just fine, and i'm ok with that. there are other ways to do this, like using /dev/tty if you know you are only using the script from a terminal. harder problem the bigger problem is that if the build fails and it might there isn't a good way to fail the whole pipeline. by default, the pipe's return value is the last return value, and cut is happy to report success as long as it runs. there are a number of possible answers. again, i could have resorted to a temporary file. however, i decided to set a bash option to cause any failing item in a pipe to fail the whole pipe immediately: set -o pipefail so now, in part, my script looks like this: set -o pipefail fn=$(pio run | tee /dev/fd/2 | grep '^renamed to' | cut -d ' ' -f 3 ) if [ $? -eq 0 ] then echo success... cp ".pio/build/stm32f103rc_creality/$fn" "configurations/$1" echo result: "configurations/$1/$fn" else echo build failed exit 3 fi final analysis is it brain surgery? nope. but it is one of those bumps in the road in what should have been a five-minute exercise. maybe next time you run into it, you'll save yourself at least 25 minutes. this gets the job done, but it isn't a stellar example of bash programming. i would hate to run it through a lint-like checker. please be kind and respectful to help make the comments section excellent. (comment policy)