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:
0
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.
Hi,
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
screenfetch
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
[edit1]
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."
fi
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
backup_dir_total_size_after=$(
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}."
backup_dir_size=$(
rclone size ${backup_dir} 2> /dev/null |
tail -1 |
sed 's/Total size: //'
) || fail
debug "Current backup directory size is: ${backup_dir_size}."
else
warn "${__BLOCK}"
more code...
fi
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
backup_dir_size=$(
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:
#!/bin/bash
function list_files() {
if ! ls -l $1 ; then
echo error listing files in $1 1>&2
kill 0
fi
}
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 test.sh here:
$ ./test.sh /
num is 48
$ ./test.sh /adfasdf
ls: cannot access '/adfasdf': No such file or directory
error listing files in /adfasdf
Terminated
Without the kill, the script continues on itās merry way when it should have failed.
After removing kill 0 from list_files function:
$ ./test.sh /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?