You are not logged in.

#1 2016-01-06 22:32:11

betseg
Member
From: Turkey
Registered: 2015-04-25
Posts: 182

sbc - a systemd-boot configurator

Hi! I wrote a little systemd-boot configurator script called sbc. Its version number is 0.1.0 tongue
Just a hobby, won’t be big and professional like GNU GRUB Customizer.

But seriously, I would be considered as "doesn't know shell scripting" and I made this script just for fun and learning.

Anyway the script:
https://github.com/betseg/sbc

Last edited by betseg (2016-01-06 22:32:47)

Offline

#2 2016-01-06 23:19:34

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,524
Website

Re: sbc - a systemd-boot configurator

That looks like a nice learning project.  It initially struck me as an odd goal - I'm dubious on the function this serves for users.  But in skimming through it, it is very well organized and clearly coded.  It looks like great shell scripting to me.

I'd suggest noting the license at the top of the .sh file, and it is common practice to note the license in version output like your function on line 33 (e.g. see `bash --version`).

You could likely simplify things like the pipeline on line 51 to be a single awk command.  Also, there doesn't seem to be a reason to run that pipeline in a subshell and store the output to a variable only to echo that variable.  Just run that pipeline in the current shell.

EDIT: example for the last suggetion: the following two code snippets do the exact same thing, but the first requires the spawning of a new instance of bash, the second does not:

        option=$(grep ${selected_option} ${file} | expand | tr -s ' ' | cut -d ' ' -f2-)
        echo $option
        grep ${selected_option} ${file} | expand | tr -s ' ' | cut -d ' ' -f2-

I'm pretty sure the following would also be equivalent, some testing may be needed:

       awk '/'${selected_option}'/ { $1=""; print; }' ${file}

"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2016-01-06 23:38:40

betseg
Member
From: Turkey
Registered: 2015-04-25
Posts: 182

Re: sbc - a systemd-boot configurator

Thank you for the suggestions! I'll make these changes tomorrow, because it's 1:38am here tongue
Thank you again!

Last edited by betseg (2016-01-07 12:26:27)

Offline

Board footer

Powered by FluxBB