101010.pl is one of the many independent Mastodon servers you can use to participate in the fediverse.
101010.pl czyli najstarszy polski serwer Mastodon. Posiadamy wpisy do 2048 znaków.

Server stats:

533
active users

#shell

2 posts2 participants0 posts today

A bash surprise: gnu.org/software/bash/manual/h says:

Functions are declared using this syntax:

fname () compound-command [ redirections ]

Usually curly braces are used for the compound command. Yet parentheses work too. And those go into a sub-shell. Run this and carefully inspect the output.

function fun() ( # parenthesis!
echo hallo
echo fun has $$ $BASHPID
)
fun
echo main has $$ $BASHPID

By using () in a function definition, we force it into a subshell. 😲

www.gnu.orgShell Functions (Bash Reference Manual)Shell Functions (Bash Reference Manual)
Nixers Newsletter #286 is out!

Dive into topics like PulseAudioDB, OpenBSD routers, shell history improvements, and more.
It's a solid edition with a gem: “Get your own home bin”, something we probably all do already in our own special ways.

https://utcc.utoronto.ca/~cks/space/blog/sysadmin/MyPersonalProgramsSetup

→ Full issue: https://newsletter.nixers.net/entries.php#286
#Unix #Linux #OpenBSD #Shell #Dotfiles #Newsletter #Nixers
utcc.utoronto.caChris's Wiki :: blog/sysadmin/MyPersonalProgramsSetup

I think I won't bother anymore with writing (bash) shell scripts that are longer than a few lines. I find the syntax too unintuitive and there are better programming languages like PHP that produce more readable code.

In the last two hours, I translated a bash shell script with ~250 lines to a PHP CLI script. The latter is nearly 400 lines long but definetly more readable and it also has more user-friendly output.

1/2

[05:45] De vervuiler verzaakt. Door deze vier fabrieken raken de klimaatdoelen uit zicht

Om het klimaatdoel van 2030 te halen, beloofden Nederlandse olieraffinaderijen – grote vervuilers – hun CO2-uitstoot tot wel 60 procent te reduceren. Maar van die beloftes komt bar weinig terecht.
Olietanks op het terrein van de raffinaderij van Shell bij Pernis. Foto: Flip Franssen / ANP.
Nog maar vijf jaar te gaan tot Nederland het klimaatdoel van 2030 gehaald moet hebben: een CO2-reductie van 55 procent ten opzichte van 1990. En laten we positief beginnen: we zijn goed op weg. De verduurzaming is in volle gang en de CO2-uitstoot daalt al jaren.
De Correspondent en maak meer verhalen mogelijk voorbij de waan van de dag.
Dankzij onze leden kunnen wij verhalen blijven maken voor zoveel mogelijk mensen.
Word ook lid!
Zakelijk lid worden is ook mogelijk,
dit kan al vanaf 5 medewerkers.
Steun ons en vraag direct een zakelijk lidmaatschap aan.
Wil je eerst kennismaken met onze verhalen?
Schrijf je dan in voor de proefmail en ontvang een selectie van onze beste verhalen in je inbox.

open.decorrespondent.nl/16033/

#2030 #Nederlandse #60procent #Shell #FlipFranssen #ANP #vijfjaar #Nederland #55procent #1990 #5

open.decorrespondent.nlInloggen - De Correspondent

Should've made this a long time ago:

function ciglob {
    #case-insensitive glob generator
    echo "$*" |while read -N1 c; do
        case "$c" in
            [a-zA-Z])   echo -n "[${c^^}${c,,}]";;
            *)          echo -n "$c"
        esac
    done
}
~ $ ciglob "Hello, world!"
[Hh][Ee][Ll][Ll][Oo], [Ww][Oo][Rr][Ll][Dd]!
~ $ ls -ld $(ciglob documents)
drwxr-xr-x 52 ~~~ ~~~ 20,480 Apr 10 11:45 Documents

(Not the most useful example, but I did have a use case in mind when I wrote it ;)

P.S. (This is a valid way to close a parenthesis. Fight me ;)

#bash#ksh#sh

#shell : the case which holds the powder, or charge of powder and shot, used with breechloading small arms

- French: coquille

- German: die Muschel

- Italian: guscio

- Portuguese: concha

- Spanish: concha

------------

Thank you so much for being a member of our community!