View previous topic :: View next topic |
Author |
Message |
John R. Graham Administrator
Joined: 08 Mar 2005 Posts: 10589 Location: Somewhere over Atlanta, Georgia
|
Posted: Fri Mar 30, 2018 3:27 pm Post subject: |
|
|
Khayyam's statement seems clear and meaningful to me, but can be modestly clarified. What khayyam meant was that non-POSIX "bashisms" are accepted by bash even when it's in --posix mode. Therefore, if your goal is strict POSIX compatibility, testing under bash is problematic.
Don't get too defensive. Technical people often jump on statements that are ambiguous or not wholly or strictly correct. This is a good thing because precision of language is important in technical endeavors. Also, we can all be better, learn things, right?
- John _________________ I can confirm that I have received between 0 and 499 National Security Letters. |
|
Back to top |
|
|
Mr. T. Guru
Joined: 26 Dec 2016 Posts: 477
|
Posted: Fri Mar 30, 2018 3:49 pm Post subject: |
|
|
@John R. Graham: the POSIX mode does not exist to test conformance to the POSIX standard. It is the designers who do this work.
This mode allows a POSIX compliant script to be executed (POSIX: Portable Operating System Interface for Unix). |
|
Back to top |
|
|
John R. Graham Administrator
Joined: 08 Mar 2005 Posts: 10589 Location: Somewhere over Atlanta, Georgia
|
Posted: Fri Mar 30, 2018 4:00 pm Post subject: |
|
|
I'm afraid you're missing the point. POSIX compliant scripts will generally work in bash without specifying --posix mode. This command line option just covers some abstruse corner cases.
- John _________________ I can confirm that I have received between 0 and 499 National Security Letters. |
|
Back to top |
|
|
Mr. T. Guru
Joined: 26 Dec 2016 Posts: 477
|
Posted: Fri Mar 30, 2018 4:17 pm Post subject: |
|
|
@John R. Graham: I assume that nobody currently uses (or consider) a Bourne Shell (sh) so my statements are still correct.
helecho wrote: | GNU Bash runs in POSIX mode if the shebang is /bin/sh [...] |
info bash wrote: | 6.11 Bash POSIX Mode
When invoked as `sh', Bash enters POSIX mode after reading the startup file. |
helecho |
|
Back to top |
|
|
John R. Graham Administrator
Joined: 08 Mar 2005 Posts: 10589 Location: Somewhere over Atlanta, Georgia
|
Posted: Fri Mar 30, 2018 4:59 pm Post subject: |
|
|
I'm afraid you're still missing the point. I'm also afraid that I've piled on and will now have to split this thread.
If you care to, take a look at what the OP actually asked about. Comments on what bash does and doesn't do with the shebang are essentially irrelevant to this thread. Certainly they're off topic.
- John _________________ I can confirm that I have received between 0 and 499 National Security Letters. |
|
Back to top |
|
|
Mr. T. Guru
Joined: 26 Dec 2016 Posts: 477
|
Posted: Fri Mar 30, 2018 5:06 pm Post subject: |
|
|
I bow! |
|
Back to top |
|
|
Naib Watchman
Joined: 21 May 2004 Posts: 6051 Location: Removed by Neddy
|
Posted: Fri Mar 30, 2018 6:19 pm Post subject: |
|
|
helecho wrote: | @Naib @khayyam: your declarations are dissapointing and disrespectful: it seems to you equal that the interlocutor has a good faith; you advocate an offensive approach.
| how? have you spontaneously contracted leprosy or something? _________________
Quote: | Removed by Chiitoo |
|
|
Back to top |
|
|
khayyam Watchman
Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Fri Mar 30, 2018 7:40 pm Post subject: |
|
|
helecho wrote: | @Naib @khayyam: your declarations are dissapointing and disrespectful: it seems to you equal that the interlocutor has a good faith; you advocate an offensive approach. |
helecho ... whatever you mean by that (as it's unclear how anyone should get from the proposition to the conclusion) I don't consider it fair criticism. As I said, you're not actually engaging with what's presented, specifically WRT to the point Hu was making, and so it seems right that this is pointed out. It also doesn't help that you consistently use english as though it's Scrabble (meaning that you get a higher meaning/score based on the words used), this isn't the case, english relies very much on tight relations between words/statements, and expressivity (or vagueness) isn't a substitute for that.
helecho wrote: | @khayyam: GNU Bash supports more features than a POSIX shell but is a POSIX capable shell. The documentation explicitly states what differs concerning POSIX features. |
You are shifting the goalposts, my question was: in what way can it be said that "bash properly considers the shebang because it adapts its operations"? As I showed, it clearly doesn't, so any argument to the tune of "bash [...] is a POSIX capable shell" means nothing here.
helecho wrote: | My statement you have previously quoted is not a criticism but a comment supporting my previous posts. My words as you interpret them are meaningless because you distort them. |
No, I didn't "distort" them, it's just that you're continuing to ignore the gist of Hu's point, and that is what what your "previous posts", and the statement "bash properly considers the shebang", was supposedly countering.
helecho wrote: | I would even say your statement is meaningless: "non POSIX "bashisms" are accepted by Bash" (see below). Stop fantasizing: I will not certify anything and certainly not POSIX! |
That would be meaningless if it were not the case that we were explicitly speaking about '--posix' and/or "POSIX mode if the shebang is /bin/sh". Your argument seems to be that because bash can interpret posix sh therefore it is '--posix', when in fact it's bash, because '--posix' makes no difference. That is, for the most part, a trivial distinction, but it's relevant in this discussion because that is what Hu was pointing out ... and you were completely ignoring!
best ... khay |
|
Back to top |
|
|
krinn Watchman
Joined: 02 May 2003 Posts: 7470
|
Posted: Fri Mar 30, 2018 8:07 pm Post subject: |
|
|
helecho wrote: | GNU Bash runs in POSIX mode if the shebang is /bin/sh and specific features are explicitly specified in the documentation. |
https://mywiki.wooledge.org/Bashism wrote: |
"function" is not defined by POSIX |
Code: | >cat test.sh
#!/bin/sh
function f { echo hello; }
f
>./test.sh
hello |
|
|
Back to top |
|
|
Naib Watchman
Joined: 21 May 2004 Posts: 6051 Location: Removed by Neddy
|
Posted: Fri Mar 30, 2018 8:55 pm Post subject: |
|
|
Also:
Bash POSIX Mode
Starting Bash with the --posix command-line option or executing ‘set -o posix’ while Bash is running will cause Bash to conform more closely to the POSIX standard by changing the behavior to match that specified by POSIX in areas where the Bash default differs. _________________
Quote: | Removed by Chiitoo |
|
|
Back to top |
|
|
John R. Graham Administrator
Joined: 08 Mar 2005 Posts: 10589 Location: Somewhere over Atlanta, Georgia
|
Posted: Fri Mar 30, 2018 9:06 pm Post subject: |
|
|
khayyam wrote: | It also doesn't help that you consistently use english as though it's Scrabble (meaning that you get a higher meaning/score based on the words used), this isn't the case, english relies very much on tight relations between words/statements, and expressivity (or vagueness) isn't a substitute for that. | Ah, but this is exactly the type of comment I would expect from an interlocutor! However, should we continue this disquisition, I'm afraid someone would accuse us of floccinaucinihilipilification. Hence, I would suggest that we both absquatulate from this topic.
- John _________________ I can confirm that I have received between 0 and 499 National Security Letters. |
|
Back to top |
|
|
khayyam Watchman
Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Fri Mar 30, 2018 10:03 pm Post subject: |
|
|
John R. Graham wrote: | Ah, but this is exactly the type of comment I would expect from an interlocutor! However, should we continue this disquisition, I'm afraid someone would accuse us of floccinaucinihilipilification. As such, I would suggest that we both absquatulate from this topic. |
Typical antidisestablishmentarianism!!! ;)
best ... khay |
|
Back to top |
|
|
pjp Administrator
Joined: 16 Apr 2002 Posts: 20067
|
Posted: Fri Mar 30, 2018 11:04 pm Post subject: |
|
|
khayyam wrote: | It also doesn't help that you consistently use english as though it's Scrabble (meaning that you get a higher meaning/score based on the words used), this isn't the case, english relies very much on tight relations between words/statements, and expressivity (or vagueness) isn't a substitute for that. | Sometimes the verbiage people use is merely that with which they are familiar and comfortable. _________________ Quis separabit? Quo animo? |
|
Back to top |
|
|
Zucca Moderator
Joined: 14 Jun 2007 Posts: 3342 Location: Rasi, Finland
|
Posted: Sat Mar 31, 2018 8:42 am Post subject: |
|
|
John R. Graham wrote: | What khayyam meant was that non-POSIX "bashisms" are accepted by bash even when it's in --posix mode. Therefore, if your goal is strict POSIX compatibility, testing under bash is problematic. |
helecho wrote: | @John R. Graham: the POSIX mode does not exist to test conformance to the POSIX standard. It is the designers who do this work.
This mode allows a POSIX compliant script to be executed. |
Therefore I declare: This discussion serves no purpose. End of story. _________________ ..: Zucca :..
Gentoo IRC channels reside on Libera.Chat.
--
Quote: | I am NaN! I am a man! |
|
|
Back to top |
|
|
khayyam Watchman
Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Sat Mar 31, 2018 10:08 am Post subject: |
|
|
khayyam wrote: | It also doesn't help that you consistently use english as though it's Scrabble (meaning that you get a higher meaning/score based on the words used), this isn't the case, english relies very much on tight relations between words/statements, and expressivity (or vagueness) isn't a substitute for that. |
pjp wrote: | Sometimes the verbiage people use is merely that with which they are familiar and comfortable. |
pjp ... in some cases yes, but what I mean by "tight relations" is the "sense" of a statement, or argument, so for example, what does the following mean: "it seems to you equal that the interlocutor has a good faith"? Using a word like "interlocutor" doesn't cover the fact that the statement is unintelligible, and if you are going to try and sound intelligent you should at least make the additional effort to say something meaningful.
best ... khay |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54232 Location: 56N 3W
|
Posted: Sat Mar 31, 2018 12:05 pm Post subject: |
|
|
This thread reminds me of the Postmans lines in this clip from Oh Mr Porter! _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
krinn Watchman
Joined: 02 May 2003 Posts: 7470
|
Posted: Sat Mar 31, 2018 1:09 pm Post subject: |
|
|
khayyam wrote: | what does the following mean: "it seems to you equal that the interlocutor has a good faith"? |
Funny because i don't see where is the problem with this one.
it seems to you equal (to nothing, so you don't care) that the interlocutor (the speaker) has a good faith (was not saying lies ; that's the one i'm less sure, as a french i would had say "was of good faith")
Learn frenglish with krinn! |
|
Back to top |
|
|
khayyam Watchman
Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Sat Mar 31, 2018 7:12 pm Post subject: |
|
|
khayyam wrote: | what does the following mean: "it seems to you equal that the interlocutor has a good faith"? |
krinn wrote: | Funny because i don't see where is the problem with this one. it seems to you equal (to nothing, so you don't care) that the interlocutor (the speaker) has a good faith (was not saying lies ; that's the one i'm less sure, as a french i would had say "was of good faith") |
krinn ... that isn't surprising, as a non-native speaker you would be inclined to make associations that fill in the gaps of familiarity. I see no absolutely no relation between "equal" and "to nothing, so you don't care". Also, the context of "seemingness" is who-knows-where, the term should underscore the perception of the author (eg, "you seem to have it all wrong") and not the reader, which is made the subject of that seemingness ("you"). If I say "it seems to you" then it's unclear who's the subject of that seemingness, whereas if I say "it seems that you" I'm stating my perception of some state of affairs. I could go on ... but for brevity's sake I'll leave it at that.
krinn wrote: | Learn frenglish with krinn! |
core blimey Monsieur!! ;)
best ... khay |
|
Back to top |
|
|
John R. Graham Administrator
Joined: 08 Mar 2005 Posts: 10589 Location: Somewhere over Atlanta, Georgia
|
Posted: Sat Mar 31, 2018 9:41 pm Post subject: |
|
|
Even so, I don't think helecho or any of the parties were acting in bad faith, nor do I think you all think so. I do think that helecho has a tendency to overestimate his level of comprehension of English (or perhaps the quality of machine translations) which leads him to take some...interesting positions.
- John _________________ I can confirm that I have received between 0 and 499 National Security Letters. |
|
Back to top |
|
|
JustAnother Apprentice
Joined: 23 Sep 2016 Posts: 186
|
Posted: Sun Jan 17, 2021 5:10 am Post subject: |
|
|
Here is a question for the experts: does it make sense to have a shebanged
file point to another shebanged file? There is very little information about
this floating around, except for an example that shebangs /bin/cat with some
text underneath, and that isn't even a double shebang.
I'm coming to the conclusion NO, for the following reasons. Maybe somebody can
say what they think about this.
I wrote a general script app called host-script.sh which shebangs bash:
The actual script file (script.sh) shebangs host-scirpt.sh like this:
Code: | #!/pathto/host-script.sh SHEBANGED |
The SHEBANGED arg shows up as the first parameter to host-script.sh,
then "script.sh" as the second parameter, then $@. The SHEBANGED part is to
tell host-script.sh that it is being shebanged. This is needed because the idea
was to have host-script.sh also run when it is soft link referent, and when it is
sourced by a script, and if shebanged.
There are a couple of problems here even if script.sh works. One is that if I
run the debugger like this:
the debug command does not propagate to host-script.sh.
The second problem is that if I run busybox it won't work:
It runs host-script.sh in bash, and it is easy to miss this, as both scripts
run in both bash and ash. Same output if they work right.
So I decided to source host-script.sh from script.sh, which just loads a
main_guts() function to call.
So back to the question: is a double shebang in general a bad idea or am I
missing something? |
|
Back to top |
|
|
WizNut n00b
Joined: 09 Nov 2005 Posts: 16 Location: Earth
|
Posted: Sun Feb 14, 2021 12:07 am Post subject: |
|
|
The “shebang” (I.e. #!) at the start of a script file is a two byte “[url=https://en.wikipedia.org/wiki/Magic_number_(programming)]magic number[/url]” that indicates to the shell that the file is a script. The path and filename following the shebang tells the shell the location and identity of an interpreter capable of running the script.
Thus:
#!/bin/bash
Tells the shell that the file is a script and that it should be run using /bin/bash.
Hopefully that explains things. |
|
Back to top |
|
|
Zucca Moderator
Joined: 14 Jun 2007 Posts: 3342 Location: Rasi, Finland
|
Posted: Tue Feb 16, 2021 10:09 pm Post subject: |
|
|
WizNut wrote: | Thus:
#!/bin/bash
Tells the shell that the file is a script and that it should be run using /bin/bash.
Hopefully that explains things. | Otherwise correct but is not the shell which reads the shebang. ;) It's the kernel.
Shell only sees the script as an executable (+x). It then calls kernel to execute the "program". Kernel see then magic number and then reads the rest to work out which program to run and pass the script filename as a first argument (unless there's predefined arguments on the shebang line).
Ok, ok... I haven't looked at bash source code, but bash could be smart and first check the existence of a shebang and then run the script if the shebang points to bash executable. Otherwise it would give kernel the control of what to do. But I highly doubt it's the case. I don't think shell developers would replicate the code that's in kernel already.
Scripts with shebang can be executed without an active shell. You can for example have a shell script as an init.
You can even create self reading text files: Code: | #!/usr/bin/tail -n +2
This is a text file. |
_________________ ..: Zucca :..
Gentoo IRC channels reside on Libera.Chat.
--
Quote: | I am NaN! I am a man! |
|
|
Back to top |
|
|
WizNut n00b
Joined: 09 Nov 2005 Posts: 16 Location: Earth
|
Posted: Wed Feb 17, 2021 12:08 am Post subject: |
|
|
see also:
man file
and
man magic |
|
Back to top |
|
|
|