LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > LinuxQuestions.org > LQ Suggestions & Feedback
User Name
Password
LQ Suggestions & Feedback Do you have a suggestion for this site or an idea that will make the site better? This forum is for you.
PLEASE READ THIS FORUM - Information and status updates will also be posted here.

Notices


Reply
  Search this Thread
Old 12-19-2016, 08:57 PM   #16
goumba
Senior Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Fedora, OpenSUSE, FreeBSD, OpenBSD, macOS (hack). Past: Debian, Arch, RedHat (pre-RHEL).
Posts: 1,335
Blog Entries: 7

Rep: Reputation: 402Reputation: 402Reputation: 402Reputation: 402Reputation: 402

Quote:
Originally Posted by szboardstretcher View Post
Good catch! Hmmm. I wonder if debian wants the () removed completely... I will spin up a debian instance to test on as well so I can cover Centos/Debian variants at least.
He was running it by invoking it
Code:
sh ldebug.sh
If you run it, invoking as bash, as you had intended, the script completes fine. There are no errors about parens.
 
1 members found this post helpful.
Old 12-19-2016, 09:14 PM   #17
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,323
Blog Entries: 28

Rep: Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141
Quote:
If you run it, invoking as bash, as you had intended, the script completes fine. There are no errors about parens.
Would you please clarify precisely what you mean by "invoking as BASH"?
 
Old 12-19-2016, 09:37 PM   #18
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Original Poster
Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
Ah yes. I think they might mean the 'sh' shell.

UPDATE -----

Script has been rewritten to the POSIX standards

Last edited by szboardstretcher; 12-19-2016 at 10:32 PM.
 
Old 12-19-2016, 09:41 PM   #19
goumba
Senior Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Fedora, OpenSUSE, FreeBSD, OpenBSD, macOS (hack). Past: Debian, Arch, RedHat (pre-RHEL).
Posts: 1,335
Blog Entries: 7

Rep: Reputation: 402Reputation: 402Reputation: 402Reputation: 402Reputation: 402
Quote:
Originally Posted by frankbell View Post
Would you please clarify precisely what you mean by "invoking as BASH"?
Strict(er) POSIX compliance when invoked as 'sh'. No bash specific features.

https://www.gnu.org/software/bash/ma...ash-POSIX-Mode

Last edited by goumba; 12-19-2016 at 09:44 PM.
 
1 members found this post helpful.
Old 12-19-2016, 09:47 PM   #20
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Original Poster
Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
OR we can convert it to POSIX compliant as suggested.


UPDATE -----

Script has been rewritten to the POSIX standards

Last edited by szboardstretcher; 12-19-2016 at 10:32 PM.
 
Old 12-19-2016, 09:47 PM   #21
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,323
Blog Entries: 28

Rep: Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141
(Grin) More homework, eh?

I made the script executable (chmod +x) on my Debian machine and it ran correctly. I'll look forward to reading up tomorrow about why that was. In any event, it might be wise to anticipate that others might also be unaware of this, especially the target audience (as we would say in the training biz) for this script.

This is something I've not run into before. Thanks to both of you.

Afterthought:

So using sh to run a script specifically invokes the shell shell, as opposed to any other shell?

Last edited by frankbell; 12-19-2016 at 09:54 PM.
 
Old 12-19-2016, 09:48 PM   #22
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Original Poster
Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
Looks like one way to check for POSIX compliance is to use a tool called 'shellchecker' that I found here: https://github.com/koalaman/shellcheck

Using this against the script should let us know if we are using any non-posix shell scripting and allow us to rewrite it ahead of time.

UPDATE -----

Script has been rewritten to the POSIX standards

Last edited by szboardstretcher; 12-19-2016 at 10:33 PM.
 
Old 12-20-2016, 10:56 AM   #23
goumba
Senior Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Fedora, OpenSUSE, FreeBSD, OpenBSD, macOS (hack). Past: Debian, Arch, RedHat (pre-RHEL).
Posts: 1,335
Blog Entries: 7

Rep: Reputation: 402Reputation: 402Reputation: 402Reputation: 402Reputation: 402
Quote:
Originally Posted by frankbell View Post
(Grin) More homework, eh?
HA. Not at all. Just figured that page could explain it better than I could.

In short, if you invoke bash using 'sh', either by
Code:
sh script
or
Code:
#!/bin/sh
bash will run in a stricter POSIX compliant mode, as the original bourne shell would have. So a lot of stuff we expect to work, will not, because they are actually bash specific.

Invoking bash as itself

Code:
bash script
or
Code:
#!/bin/bash
will allow a script to use those bash specific builtins and syntax.

There seem to be a few things (myself included) do when we write shell scripts that are bash specific, but don't realize it until cases like this. Some are obvious, some documented better than others.

Last edited by goumba; 12-20-2016 at 11:32 AM.
 
Old 12-20-2016, 08:03 PM   #24
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,323
Blog Entries: 28

Rep: Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141
Quote:
If you run it, invoking as bash, as you had intended, the script completes fine. There are no errors about parens.
As an aside, there's still the nagging question as to why

Code:
sh [scriptname]
worked in CentOS and Slackware and not in Debian and Mint.
 
Old 12-20-2016, 08:57 PM   #25
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Original Poster
Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
sh can be a symlink back to bash or dash.
 
Old 12-21-2016, 03:40 PM   #26
goumba
Senior Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Fedora, OpenSUSE, FreeBSD, OpenBSD, macOS (hack). Past: Debian, Arch, RedHat (pre-RHEL).
Posts: 1,335
Blog Entries: 7

Rep: Reputation: 402Reputation: 402Reputation: 402Reputation: 402Reputation: 402
Quote:
Originally Posted by frankbell View Post
As an aside, there's still the nagging question as to why

Code:
sh [scriptname]
worked in CentOS and Slackware and not in Debian and Mint.
Debian and derivatives use dash as the default shell. Although I haven't looked into it, perhaps that explains the discrepancy.
 
Old 12-23-2016, 05:33 AM   #27
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Get Some!

Quote:
Originally Posted by szboardstretcher View Post
A very simple mockup is available here: https://github.com/boardstretcher/ldebug
I'd be interested in collaborating.
  1. Shouldn't we 'represent' LQ with lqdebug and not ldebug?
  2. output to a pastebin-like URI?
Seems the poor dears can't find the code boxen to save their lives. Bless their hearts.

More than enough diverse hosts to run any script against.

Subscribed with interest...

Last edited by Habitual; 12-23-2016 at 05:34 AM.
 
1 members found this post helpful.
Old 12-29-2016, 09:42 AM   #28
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Original Poster
Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
Quote:
Originally Posted by Habitual View Post
I'd be interested in collaborating.
  1. Shouldn't we 'represent' LQ with lqdebug and not ldebug?
  2. output to a pastebin-like URI?
Seems the poor dears can't find the code boxen to save their lives. Bless their hearts.

More than enough diverse hosts to run any script against.

Subscribed with interest...
Good points. I would not name it lqdebug without the blessing of Jeremy. So to keep it general and without official ties to LQ I think it should stay 'ldebug'.. That was my thought.

Changed the pastebin line to be more general.

Would love to have you collaborate. Just fork and pull request any changes/additions you would like. Thanks for your input.

One thing I was thinking of was allowing auto-pasting to the related LQ thread number as a 'ldebug output reply' or something. I could do that real simple like if there were an API, but my username/password + curl request is a bit rusty to do so. Seem like something you could shine light on?

Last edited by szboardstretcher; 12-29-2016 at 09:47 AM.
 
Old 12-29-2016, 09:51 AM   #29
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
heres my attempt:
http://www.linuxquestions.org/questi...ng-4175509407/

inxi mite make this redundant ?
 
1 members found this post helpful.
Old 12-29-2016, 10:15 AM   #30
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Original Poster
Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
It's just a pet project. Everything has been done before. Bashtool, ohai etc... But i'm trying to keep ldebug wayyyyyyyyyyyyyyy smaller than 15000 lines and easy to read and understand.

Most likely it will disappear into obscurity or never be used by anyone but myself,.. but until then it's hopefully a nice way to collaborate and talk with other interested LQ members. It's nice to be a part of making something useful. And it's in bash - so no one has to take hours out of their day to debug and contribute. Someone can just add a good command and call it a day. Or make a suggestion. That sort of thing.

Last edited by szboardstretcher; 12-29-2016 at 10:16 AM.
 
3 members found this post helpful.
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Basic troubleshooting AIO RDO Havana Instance on CentOS 6.5 LXer Syndicated Linux News 0 04-29-2014 09:41 AM
Performance troubleshooting tool amoralejo Linux - Server 4 02-01-2009 12:26 PM
LXer: Basic Veritas Cluster Server Troubleshooting http LXer Syndicated Linux News 0 11-14-2008 11:20 AM
LXer: traceroute - a very useful troubleshooting tool which reveals the bottlenecks on the Internet LXer Syndicated Linux News 0 01-18-2007 12:33 PM
Basic Sound troubleshooting steps? penguinlnx Linux - Software 3 03-16-2005 12:49 AM

LinuxQuestions.org > Forums > LinuxQuestions.org > LQ Suggestions & Feedback

All times are GMT -5. The time now is 02:48 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