-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
style-guide: document use of POSIX-compliant shell syntax in subdirectory common
#12894
base: main
Are you sure you want to change the base?
Conversation
common
> More information: <https://www.gnu.org/software/bash/manual/html_node/Word-Splitting.html>. | ||
``` | ||
|
||
To help you decide using POSIX-compliant syntax, ask yourself this: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about the wording of this section, maybe we can reword it a bit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To help you decide using POSIX-compliant syntax, ask yourself this: | |
To help you decide using POSIX-compliant syntax, use the below questions: |
Co-authored-by: K.B.Dharun Krishna <[email protected]>
I personally see no reason why tldr should be POSIX compliant... In my view, this project's aim is to be useful for beginners, showing them how to do useful, real-world stuff. Restricting yourself to the POSIX standard is not real-world at all, basically everyone uses modern shells like bash or zsh that allow for convenience features like process substitution. I argue that users that restrict themselves to pure POSIX shells, be it for ideological reasons or limitations of their system (e.g. if they work with embedded devices), are very well aware of the limitations of this choice and will not be surprised if some examples in tldr cannot be copy-pasted on their system. I would be in favour to remain non-compliant to POSIX, at least a little bit where it makes sense. E.g., lets keep process substitution but remove instances of |
@gutjuri I think beginners don't even care if they use bash or something else. They just use terminal, probably the default for their system. I don't care either (I'm just using bash which is the default on Fedora). |
To help you decide using POSIX-compliant syntax, ask yourself this: | ||
|
||
- Is the example too long (i.e. [exceeds the maximum line length](https://github.com/tldr-pages/tldr/blob/main/.markdownlint.json#L5))? | ||
- Does the example utilize any [risky](https://unix.stackexchange.com/a/278439) or [inefficient](https://unix.stackexchange.com/a/169765) commands? | ||
- Does the example return the correct output? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To help you decide using POSIX-compliant syntax, ask yourself this: | |
- Is the example too long (i.e. [exceeds the maximum line length](https://github.com/tldr-pages/tldr/blob/main/.markdownlint.json#L5))? | |
- Does the example utilize any [risky](https://unix.stackexchange.com/a/278439) or [inefficient](https://unix.stackexchange.com/a/169765) commands? | |
- Does the example return the correct output? | |
As more of the points below apply, so does the recommendation to not use POSIX-compliant syntax in a particular example: | |
- The example is not implemented in at least one version | |
- The example is too long (i.e. [exceeds the maximum line length](https://github.com/tldr-pages/tldr/blob/main/.markdownlint.json#L5)) | |
- The example utilize any [risky](https://unix.stackexchange.com/a/278439) or [inefficient](https://unix.stackexchange.com/a/169765) commands? | |
- The example doesn't return the correct output in some or all implementations |
How about this? @kbdharun @sebastiaanspeck @tricantivu
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO questions makes things a bit too open and a bit confusing (a positive answer means that I should use POSIX-compliant syntax or not?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO questions makes things a bit too open and a bit confusing (a positive answer means that I should use POSIX-compliant syntax or not?)
Perhaps I could replace the questions for a guide explaining how to check POSIX-compliance (e.g. shellcheck -s sh -
).
In my opinion, tldr should mostly be POSIX compliant if the platform is
IMO the project is targeted at all types of users. Obviously it is useful for begginers, but I definitely see how it can be useful for mid-level users and even for extremely experienced users. For example, one can have a deep knowledge in a specific area but doesn't know how to use a new tool. If the person wants to just get the most useful examples quickly, tldr can be used, instead of reading the official documentation (if any) or manual pages.
If we target all popular Unix-like platforms, from Linux to BSDs, we should try to use POSIX. Particularly, OpenBSD tries to follow POSIX for most of their commands. POSIX is basically the only way to assure cross-compability with even some more obscure OSes, which adds, in the long term, a big value to tldr at a relatively low cost.
BSDs don't use neither bash or zsh, Also, POSIX compliance is important in the shell scripting community.
Your example is a good one. If that syntax is not supported in "modern shells" (bash, zsh and fish?), IMO we should keep them in I see no problem if, for example, if the Edit.: In my view, we should:
If a not universal command or option is used, a note or warning should be used. |
Co-authored-by: K.B.Dharun Krishna <[email protected]>
Co-authored-by: Sebastiaan Speck <[email protected]>
Only for pages in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do lines 398-411 have an extra space at the start of each line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Editing mistake
common
,linux
,osx
,windows
,sunos
,android
, etc.Closes #12694.
I decided to suggest rather than oblige (hence the
should be written...
) users to write command examples with POSIX-compliant shell syntax because I and probably other reviewers will agree that some pages could become less useful in the long run.