[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip / qa] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: Scarface-TWIY-12.jpg (40 KB, 640x640)
40 KB
40 KB JPG
when writing bash scripts for server stuff and simple automations, what's your take on complexity?

would you rather have a script that performs a few dozen checks before executing its simple command or would you like to just shovel in the command assuming it's all good?
>>
>>100189830
start simple, add checks as you face issues
>>
File: based.jpg (981 KB, 1604x1128)
981 KB
981 KB JPG
>>100189830
I would take the rather complicated route, but not your take.

All my server scripts used a deployment script installing all dependencies, creating symlinks, installing services if necessary.
But I'm done with system administration (at least for companies)
>>
The whole point of scripting is to be simple and fast. If you need a lot of sanity checking, write a proper program. Also, scripts should only be run by people that know what they're doing. They're not supposed to be deployable or portable.
>>
>>100189830
who's going to be using it?
if it's just you, then only add as much stuff as you need ie. not much because you should remember how your own tool works

also, depends what the simple command is;
definitely DO add a bunch of checks/confirm prompts if it could accidentally destroy stuff.
eg. possibly use --interactive if doing rm

if it's getting called with any input that you don't control the source of, then quite possibly forget it.
>>
cool, thanks dudes
>>
You shouldn't need to check anything beyond arguments passed to your script, you should know what's available on your system and write script accordingly.
>>
If it performs 5-10 commands and maybe some pipes, I use Bash. Once the thing becomes anything larger than that, I switch to ansible. Saves me mamy hours of dealing with bash's retarded syntax and other oddities
>>
File: 1658440923476741.jpg (90 KB, 824x983)
90 KB
90 KB JPG
unless you literally only need to run 2-3 commands, just use python
bash has some of the most retarded stuff ever
>>
>>100191656
>>100190603
I've become used to bash's oddities
it's over.....



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.