News for hackers. Stuff that matters.
Re:Writing Safe Shell Scripts (2019) by zelly on Saturday February 01, 2020 @07:57PM (#22214395)
The shell is the true user interface to the OS. I like to think of writing shell scripts as having some mouse clicking automation tool on a GUI shell. It should be viewed as just as kludgy of a solution. But there really isn't anything more convenient most of the time. Shell scripts are to be called by humans to automate behavior they otherwise would have had to do manually.

An application should never rely on a shell script. If you have to execute another program, use the syscalls (fork and exec on posix).

Re:Writing Safe Shell Scripts (2019) by effie on Sunday February 02, 2020 @11:45AM (#22217800)
> An application should never rely on a shell script. If you have to execute another program, use the syscalls (fork and exec on posix).

Could you explain why? I'm very happy with programs calling shell commands/scripts. You execute another program the same way whether interactively from a shell, or by calling system() from another program. The simplicity and universality of the call syntax is an advantage.

Re:Writing Safe Shell Scripts (2019) by zelly on Sunday February 02, 2020 @12:52PM (#22218203)
Security. system() is one of the most common targets for hacking (getting a shell by manipulating the string passed to system() by various means). Calling programs from the kernel directly is a lot more well-behaved. You're limited to only executing one program.