Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Book about dash shell

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
User avatar
LinuxOS
Posts: 52
Joined: 2022-07-31 01:46
Has thanked: 27 times
Been thanked: 3 times

Book about dash shell

#1 Post by LinuxOS »

Hello.
Is there any book I can buy about dash shell?
I have a couple books on bash shell, but cannot find any about dash shell.
Or at least a book about strict POSIX shell programming without any features unique to bash, ksh, zsh.
Thank you for the answers.

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: Book about dash shell

#2 Post by Head_on_a_Stick »

The Open Group publishes a nice usage guide for POSIX sh:

https://pubs.opengroup.org/onlinepubs/9 ... hap02.html

And I like these guides:

https://www.grymoire.com/Unix/Sh.html

https://drewdevault.com/2018/02/05/Intr ... shell.html

POSIX sh ftw!

EDIT: Greg's Wiki has a page that covers the differences between bash & POSIX sh:

https://mywiki.wooledge.org/Bashism
deadbang

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Book about dash shell

#3 Post by p.H »

I find dash(1) man page quite comprehensive.

Personal observation: the implementation of the 'echo' builtin in dash is quite different from other common shells such as bash or busybox ash or the standalone 'echo' command from coreutils. It does not support -e|-E and behaves like others with -e. It seem that 'echo' is not strictly specified by POSIX. If consistent behaviour is needed with different shells, it is better to use 'printf' instead.

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: Book about dash shell

#4 Post by Head_on_a_Stick »

p.H wrote: 2022-07-31 19:07 It seem that 'echo' is not strictly specified by POSIX
The only recognised option is -n and that is only specified for XSI-conformant systems.
Application Usage wrote:It is not possible to use echo portably across all POSIX systems unless both -n (as the first argument) and escape sequences are omitted.

The printf utility can be used portably to emulate any of the traditional behaviors of the echo utility
I sometimes use this in scripts:

Code: Select all

echo () { printf %s\\n "$*" ; }
For the reasoning see Printing the value of a variable.

@LinuxOS, be sure to pass your scripts through checkbashims(1) (from the devscripts package) and https://www.shellcheck.net/ (there is a package but it's Haskell-based and regularly updated so the web interface is probably better).
deadbang

User avatar
LinuxOS
Posts: 52
Joined: 2022-07-31 01:46
Has thanked: 27 times
Been thanked: 3 times

Re: Book about dash shell

#5 Post by LinuxOS »

Thank you for the answers.
Reading a page at this link https://www.etalabs.net/sh_tricks.html I found an opinion that "Bourne-derived languages are extremely bad, on the same order of badness as Perl" with the link https://www.etalabs.net/erik-perl.txt explaining how bad Perl language is. I always thought that Perl is one of the most robust languages and is used in mission-critical systems.

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: Book about dash shell

#6 Post by Head_on_a_Stick »

I can't comment on Perl, I've never actually used it.

OpenBSD uses it for their package manager though:

https://github.com/openbsd/src/blob/mas ... pkg_add#L1

So it can't be that bad. EDIT: although it is criminally slow :mrgreen:
deadbang

arzgi
Posts: 1185
Joined: 2008-02-21 17:03
Location: Finland
Been thanked: 31 times

Re: Book about dash shell

#7 Post by arzgi »

When dash was new, I saw a one page maybe pdf-document, where differences to bash were explained. I had to minor modifications to my scripts.

Have you tried bash vs dash net search?

User avatar
LinuxOS
Posts: 52
Joined: 2022-07-31 01:46
Has thanked: 27 times
Been thanked: 3 times

Re: Book about dash shell

#8 Post by LinuxOS »

arzgi wrote: 2022-08-02 09:16

Have you tried bash vs dash net search?
Yes, I have found this https://github.com/dylanaraps/pure-sh-bible

Linux29
Posts: 2
Joined: 2023-02-17 16:05
Has thanked: 4 times

Re: Book about dash shell

#9 Post by Linux29 »

You might want to consider The Linux programming interface from Michael Kerrisk. This book contains multiple chapters about POSIX :D

Post Reply