Return to

The small linux problem thread



its the return status $?


Yep that’t it, he has exit code in is $PS1


Yeah, it makes sense now. I’ve been staring at this too long.

Here’s one that is getting frustrating…

[ ${__ABORT} -eq 1 ] &&
echo ${__ABORT} &&
debug "Backup was aborted. Compiling report."

is generating:

2019/02/17 00:45:37 DEBUG : Backup was aborted. Compiling report.


I have a problem with switching my audio adapters in Fedora 29. I have headphones plugged in the front I/O of my case and the speakers in the MB at the back. I only get audio from the headphones. I switch to the other adapter inside the audio settings and silence.
Edit to add: on windows I just click on the speaker next to the clock and choose the output. In fedora, this isn’t the case.


On my main machine man -k doesn’t seem to work, man -K works but is not the same

command taken from the man manpage

$ man -k printf
printf: nothing appropriate.

just doing man printf gives the expected result


OS: Arch Linux
Kernel: x86_64 Linux 4.20.8-arch1-1-ARCH
Uptime: 34m
Packages: 1284
Shell: bash 5.0.0
Resolution: 4480x1440
WM: i3
GTK Theme: deepin [GTK2/3]
Icon Theme: deepin
CPU: Intel Core i7-4770K @ 8x 3.9GHz [27.8°C]
GPU: GeForce GTX 970
RAM: 2753MiB / 15988MiB

For some reason i didn’t think about searching for man -k nothing appropriate, after doing that i found an answear, sorry for posting this


What shell are you using?
Shouldn’t that be (for bash):

if [ ${__ABORT} -eq 1 ]; then
echo ${__ABORT} 
debug "Backup was aborted. Compiling report."


I had an || before it that was messing it up.

I like to use && and || for logic and error handling. Like this:


Good to know, I’m gonna bookmark this.


It has a nice unixy flow to it. I probably overdo it, but here’s the script I was working on:

There are aspects of it that I still need to test, but the basics work.

It adds lock file, email reporting and simplified arguments to rclone and will automatically copy/sync from the most recent zfs snapshot with the -S flag.


I sort of prefer the if then style. The && and || make the logic harder to follow. (I’m not saying you should change it, use whatever style makes it easier to maintain – that’s the important part)

For example:

if [ $use_backup_dir -eq 1 ] ; then
    rclone size $( dirname ${backup_dir} ) 2> /dev/null | 
      tail -1 | 
        sed 's/Total size: //'
  ) || fail

  debug "Total backup directory size is: ${backup_dir_total_size_after}."
    rclone size ${backup_dir} 2> /dev/null |
      tail -1 |
        sed 's/Total size: //' 
  ) || fail

  debug "Current backup directory size is: ${backup_dir_size}."
  warn "${__BLOCK}"
  more code...


Another thing that bothers me is that there is no way to catch the return status from a piped command. The return status is always the last command executed.

So, this

    rclone size ${backup_dir} 2> /dev/null |
      tail -1 |
        sed 's/Total size: //' 
  ) || fail

Doesn’t work, since sed will always succeed, even if rclone fails. The status has to be sent via signal to cause the pipeline to stop running. Like this:


function list_files() {
  if ! ls -l $1 ; then
    echo error listing files in $1 1>&2
    kill 0

function show_number() {
  local num=$(
        list_files $1 |
          head -1 |
            sed -e 's/total //'
  echo num is $num

show_number $1

When list_files fails, it signals that so that show_number never runs. The above is in a script called here:

$ ./ /
num is 48
$ ./ /adfasdf
ls: cannot access '/adfasdf': No such file or directory
error listing files in /adfasdf

Without the kill, the script continues on it’s merry way when it should have failed.

After removing kill 0 from list_files function:

$ ./ /adfasdf
ls: cannot access '/adfasdf': No such file or directory
error listing files in /adfasdf
num is

Num is set to the null string when the directory doesn’t exist since the shell script continues to run.

More on the pipe status in this stack overflow


For some reason my laptop isn’t getting a default route when connecting via ethernet. It pulls DHCP fine (gets a /8 route instead of a /24 for some reason) but has no default gateway.
Using NetworkManager btw.


Boot another os and see what address it gets


Just tested another laptop, and it does the same thing. /8 route instead of /24 no gateway set, no default route.
Also running NetworkManager, but this laptop is Ubuntu running default configs instead of Gentoo.


Bad DHCP server settings?


Remember kiddos… when you install in CSM mode and boot in UEFI mode you’re going to have a bad time.


That’d be my guess.


I’m having trouble installing steam. it appears to install just fine, both through the CLI and the ubuntu app store but it won’t launch. I have an HP Envy x360 ryzen 5 2500u model, running Ubuntu 18.10 running the linux kernel 4.20.10


What does it spit back if you try running it from a Terminal Emulator?


how do you do that?