Hi Yubao, Great to see that pkgmk is getting more attention. Liu Yubao <yubao.liu@gmail.com> wrote:
diff --git a/pkgmk.in b/pkgmk.in index 9bf381d7..9d75a82a 100644 --- a/pkgmk.in +++ b/pkgmk.in @@ -65,8 +65,7 @@ get_filename() { }
get_basename() { - local FILE="`echo $1 | sed 's|^.*://.*/||g'`" - echo $FILE + echo "${1##*/}" }
I wonder if that was the ulterior motive behind GNU grep's recent changes: force the maintainers of legacy shell scripts to comb through the code to eradicate instances of "egrep", so that downstream users see a flurry of activity and then feel empowered to propose new optimizations themselves. bash parameter expansions as proposed (trim the leading pattern or trailing pattern in a string) are already used elsewhere in pkgmk (see the refresh_signature function). But because the refresh_signature function was added at a different time than the get_basename function, you can see the evidence of two different coding styles. Running shellcheck on /usr/bin/pkgmk reveals not just the parameter expansion alternative proposed by Yubao (SC2001), but a number of other places where cleaner (more modern?) alternatives are possible. Traces of different coding styles from the earliest days of CRUX up to the present are still visible in pkgmk, which makes it a useful repository of distro history. To overhaul all the anachronisms in one single commit and rewrite them in a uniform style would represent a sharp discontinuity in our distro's evolution. But some CRUX users have been bold enough to attempt it, including Fun [1] and myself [2]. Fun had the more ambitious goal of trimming out all the cruft that pkgmk had accumulated over the years. I took inspiration from Fun's work and expanded upkgmk into a drop-in pkgmk replacement, using more modern shell conventions throughout (as recommended by shellcheck). My pkgmeek script also has some experimental support for native treatment of git sources (so you don't have to put your "git clone" commands in the build function), but ports that make use of that feature must remain unpublished until the same support appears in official CRUX tools. [1] https://gitlab.com/therealfun/oprt/-/blob/master/src/upkgmk [2] https://git.sdf.org/jmq/Documentation/src/branch/master/scripts/pkgmeek I appreciate Yubao's effort to draw attention to this vital script. Thanks for getting the conversation started. -- John