OS400/makefile.sh: fix shellcheck warning SC2038 - #19451
Conversation
Seems to not trigger anymore as of shellcheck 0.11.0
|
|
||
| # shellcheck disable=SC2038 | ||
| find "${TOPDIR}" -type f -print | xargs ls -S | while read -r CCSID FILE | ||
| find "${TOPDIR}" -type f -print0 | xargs -0 ls -S -- | while read -r CCSID FILE |
There was a problem hiding this comment.
This breaks OS400 builds: neither -print0 nor xargs -0 supported on OS400.
There was a problem hiding this comment.
Is there a reason to use ls -S (sort by size) in this case? i.e. would this work to avoid the warning?:
find "${TOPDIR}" -type f | while read -r CCSID FILEThere was a problem hiding this comment.
Is there a reason to use ls -S ...
Yes: the -S option causes the file's encoding (CCSID) to be displayed. as this sequence makes sure files are UTF8-encoded, this is mandatory.
You should never assume qshell commands are GNU-compatible: POSIX is generally a good subset.
There was a problem hiding this comment.
IMHO, you better should exclude completely qshell scripts from your checks.
There was a problem hiding this comment.
I don't think making certain files "off-limits" is a solution.
There was a problem hiding this comment.
Going with this, -print is optional as in POSIX, -- is supported according to Qshell PDF:
find "${TOPDIR}" -type f | xargs ls -S -- | while read -r CCSID FILE
FWIW I can see no GNU things here, and in POSIX ls -S has a different meaning:
Sort with the primary key being file size (in decreasing order) and the secondary key being filename in the collating sequence (in increasing order).
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/ls.html
find: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/find.html
Qshell PDF here: https://www.ibm.com/docs/en/ssw_ibm_i_74/pdf/rzahzpdf.pdf
There was a problem hiding this comment.
If it's in the repository it cannot be off-limits IMO.
There was a problem hiding this comment.
find "${TOPDIR}" -type f | xargs ls -S -- | while read -r CCSID FILE
Yes, this should work. The -print and -- have never be the problem.
If it's in the repository it cannot be off-limits IMO.
What do you mean by "off-limits"?
There are plenty of "foreign" command syntaxes under the packages directory, i.e.: vms/*.com.
If the .sh extension confuses you, I can rename those files.
There was a problem hiding this comment.
No, .sh doesn't confuse me. What confuses everyone (incl. tools) is that these shell scripts have the #!/bin/sh POSIX shell shebang, while apparently they have nothing to do with the POSIX standard.
There was a problem hiding this comment.
It's not a very good experience when one hears first of "qshell" while being scolded for trying to maintain and as a consequence blindly fix what looks like a standard script!
edit: qshell has a single mention at the end of the OS/400 readme, in a way that's hard to guess it's related to .sh scripts (and impossible if someone doesn't know what to look for!). And 2 hits when searching in past issues, this being the 3rd one. Perhaps this could use a bit more emphasis, I linked to the documentation in the latest commit, for the next person trying to figure this out from nothing.
Reported-by: Patrick Monnerat Bug: #19451 (comment) Follow-up to af5a164 #19451 Closes #19482
Let me see if we can suppress the shebang. I'll come back later on this.
Sure., and I don't blame you but rather thank you to keep maintaining these files according to your views and changes elsewhere.
This document is primarily oriented towards OS/400 people wanting to use/compile/develop with curl on their favorite platform. I did not think of OS/400-unaware people when I wrote it. Maybe I should write some other document for curl developers? |
I just performed a build without the shebangs successfully. Would you like I drop them ? |
I think it's enough if the scripts have e.g. a comment saying what Since by and large they are POSIX-compliant, the shebang can Perhaps having fewer scripts by merging them could help, and |
Ref my other comment, I think it's better to have some shebang, and For this particular issue it'd be nice to find something that passes this |
If I correctly understand the "issue": the original command incorrectly deals with names containing spaces and those starting with an hyphen. Right? |
Also quotes in filenames. Here's what shellcheck says about it: They are not in the curl repo, but there is no guarantee there aren't any |
|
OK, there are probably hidden behaviors there as the top find directory is the curl tree. I wouldn't go deeper on that. I started trying to imagine how we can do it, but qshell's xargs has no -d, -I options: |
|
Zooming out a step, what is the reason to convert files to UTF-8? curl sources have been purged from UTF-8 characters earlier this The letter If mqtt sources are the remaining blocker, and UTF-8 is making things |
There are some Perl invokations during the build and the Perl interpreter is not an OS/400 program, but a PASE one.
No I'm afraid, because we still need transcoding to an ASCII-based CCSID! But thanks anyway for the suggestion. |
Also:
Seems to not trigger anymore as of shellcheck 0.11.0