Earlier quoted context omitted.
Another approach is to have powerful enough language that allows you to guard against the shell injection. I wrote a syntax form allowing to do this: (sh "cat " file " >" output) With file being bound to "foo'bar" and output to "x", it is automatically translated into cat 'foo'\''bar' >'x' This gives you the flexibility to use shell (sometimes it just is the most concise way) while being safe against injection. I bel…
How do you know which shell you're escaping for? You could query the system, but now you end up implementing escaping for every shell out there.
Use Long Options in Scripts
71–80 of 157 posts
Re: Use Long Options in Scripts
#72Earlier quoted context omitted.
Because not everyone has 20 or more years of flag memory from using Linux It's called learning , apparently something that is now being eschewed in favour of quick superficiality (and making developers more replaceable --- with AI or unskilled offshore labour.) No wonder "modern" software is almost always total shit. "But I don't have the time to learn," you complain, but ask yourself this instead: Why do you never h…
Learning that this tool can be used do these things, manipulate these objects or stream of data like this, and that this tool is useful in combination with these other tools are the valuable part. Memorizing some arbitrary encoding of the parameters are not really useful when I can offload it to my language center in the brain and basically get that part for free...
Re: Use Long Options in Scripts
#73Unfortunately, if you want your scripts to be portable to other POSIX systems you might have to use the short options, as the long ones are not standardized. You have to decide the tradeoff for yourself.
What POSIX systems in actual use (not historical Unixes) don't have the long options? macOS' BSD utilities I guess?
Re: Use Long Options in Scripts
#74Earlier quoted context omitted.
What POSIX systems in actual use (not historical Unixes) don't have the long options? macOS' BSD utilities I guess?
> What POSIX systems in actual use (not historical Unixes) don't have the long options? All of them except for GNU, AFAICT? (That is, only GNU seems to have long options.) Checking manpages for rm(1) as a simple reference, I can't see long options in any of the 3 major BSDs or illumos, and checking Alpine Linux seems to show busybox also only doing short options (sorry, can't find an online doc for this, though it's…
Re: Use Long Options in Scripts
#75Re: Use Long Options in Scripts
#76Please DO NOT mix string interpolation and command execution, especially when a command is processed through the shell. Whatever your language, use a list-based or array-based execution API that passes arguments straight through to execv(2), execvp(2), etc, bypassing the shell.
But for a simple example like this where it's inserting a date which has known properties, it seems fine, and is much more readable.
Re: Use Long Options in Scripts
#77Earlier quoted context omitted.
Because not everyone has 20 or more years of flag memory from using Linux, and they’ve also got to maintain the scripts. If you’re not familiar with every arcane invocation of find or tar or whatever, or even if it’s just been a while, the long options are a godsend when you’re skimming a script trying to figure out what it’s doing.
Because not everyone has 20 or more years of flag memory from using Linux It's called learning , apparently something that is now being eschewed in favour of quick superficiality (and making developers more replaceable --- with AI or unskilled offshore labour.) No wonder "modern" software is almost always total shit. "But I don't have the time to learn," you complain, but ask yourself this instead: Why do you never h…
Re: Use Long Options in Scripts
#78Earlier quoted context omitted.
Programs are read more often than they're written, and on a scale of decades all programmers are novices. So I try to optimize my code to be obvious to novices What's wrong with GNU? they automatically wrong or something?
So I try to optimize my code to be obvious to novices That's the attitude which is responsible for making software the way it is today: mediocre.
Software isn't as exciting any more, but that excitement isn't gone because newbs don't have to look up what -O stands for anymore. It's because it's wildly more reliable.
Re: Use Long Options in Scripts
#79Earlier quoted context omitted.
This surprises me because the first case I remember ever coming across where short versus long options impacted portability across GNU and BSD was _fixed_ by using long options. Maybe six years ago or so I had an issue porting a script someone else had written for use in CI that happened to decode some base64 data that failed when I tried to use it on a different platform. I forget which one it was originally written…
I think the right way to think about this (if your goal is to avoid surprises at least) is that options (short or long) are just strings. There's no guarantee that there's a long variant of an option. There's not even a requirement that options start with a dash. A sufficiently brain-damaged developer could start them with a slash or something. If you're going for portability the best bet is to just read the manual f…
I would never write a new program with this option, but I do find it a delightful historical oddity.
Re: Use Long Options in Scripts
#80Earlier quoted context omitted.
Only if you are getting input from untrusted users
imo it's best to just avoid it altogether. Requirements change, and what was once a trusted input can become untrusted input.