LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 12-28-2022, 02:14 PM   #31
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,066

Rep: Reputation: Disabled

Quote:
Originally Posted by metaed View Post
I generally avoid shell extensions
Me too. I only use constructs specified by POSIX in Shell Command Language. DrewDeVault elaborated why in his Introduction to POSIX shell. And i use shellcheck which also finds most of my mistakes.
 
2 members found this post helpful.
Old 12-28-2022, 02:58 PM   #32
metaed
Member
 
Registered: Apr 2022
Location: US
Distribution: Slackware64 15.0
Posts: 372

Rep: Reputation: 172Reputation: 172
Quote:
Originally Posted by Didier Spaier View Post
I only use constructs specified by POSIX
That was a very engaging rabbit hole. I am already aware of and frequently consult the POSIX standard, but I was not aware of the Almquist shell (ash/dash): a shell implementation that conforms closely to the POSIX standard, and is part of the Slackware distro. In fact the paragraph describing the Almquist shell for Slackware claims that ash is the shell used by the Slackware install disks.

Relinking /bin/sh to /bin/dash would probably break too many things, no matter how much I'm tempted.

Now I'm considering whether it would be fun to write a true Bourne clone, as such a thing apparently does not exist.
 
Old 12-28-2022, 03:10 PM   #33
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
Quote:
Originally Posted by metaed View Post

Here's a demonstration. This solution is more readable than my original, but designed to be shell-independent. Per your suggestions, it uses the shell for parsing, employing a subshell to avoid importing unused variables.
I get your point (especially if you intend to publish a shell utility), although I would prefer the bash way as it opens /etc/os-release only one time, I admit I generally prefer bash syntax over the shells I tried before
 
Old 12-28-2022, 04:26 PM   #34
metaed
Member
 
Registered: Apr 2022
Location: US
Distribution: Slackware64 15.0
Posts: 372

Rep: Reputation: 172Reputation: 172
Quote:
Originally Posted by metaed View Post
Now I'm considering whether it would be fun to write a true Bourne clone
Didn't have to ... it's alive! https://slackbuilds.org/repository/1...m/heirloom-sh/
 
Old 12-29-2022, 01:03 AM   #35
henca
Member
 
Registered: Aug 2007
Location: Linköping, Sweden
Distribution: Slackware
Posts: 996

Rep: Reputation: 675Reputation: 675Reputation: 675Reputation: 675Reputation: 675Reputation: 675
Quote:
Originally Posted by metaed View Post
but designed to be shell-independent.
Quote:
Originally Posted by metaed View Post
Passes Slackware 15's Bash and Korn shells, with and without -oposix. It is likely to pass even a real Bourne shell, because it uses backquotes instead of $() for command substitution.
The fact that it works in bourne-like shells might not be enough to call it "shell-idependent". What about tcsh for example? Tcsh has a completely different syntax for setting environment variables.

regards Henrik
 
Old 12-29-2022, 09:05 AM   #36
metaed
Member
 
Registered: Apr 2022
Location: US
Distribution: Slackware64 15.0
Posts: 372

Rep: Reputation: 172Reputation: 172
Quote:
Originally Posted by henca View Post
What about tcsh
[t]csh was designed to be incompatible. This is like asking "what about PowerShell".
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Google's tips and tricks guide for Android users LXer Syndicated Linux News 0 07-27-2016 03:57 PM
nVidia - No diversion 'diversion of /usr/lib/xorg/modules/extensions/libglx nicolasdiogo Linux - Hardware 2 12-31-2012 08:14 AM
GNOME:(Convenience) Any way to input shell commands without bringing up a terminal? kopatops Linux - Software 6 03-13-2010 04:05 PM
LXer: Tips4Linux.com - Tips and Tricks for Linux Users LXer Syndicated Linux News 0 07-14-2009 03:30 PM
Ubuntu 5.10 -> 6.06: diversion of /usr/bin/ldd to /usr/bin/ldd.amd64 by ia32-libs HellSpawn Linux - Software 2 06-04-2006 09:18 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 05:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration