For a while I've been using a simple command in a little script to fetch Arch PKGBUILDs (./PKGBUILD-get pkgname)
Code: Select all
#! /bin/sh
PKG=$1
git clone https://gitlab.archlinux.org/archlinux/packaging/packages/$PKG.gitCode: Select all
#! /bin/sh
PKG=$1
rm -rf $PKG_old > /dev/null 2>&1
mv $PKG $PKG_old > /dev/null 2>&1
git clone https://gitlab.archlinux.org/archlinux/packaging/packages/$PKG.gitIn this case, the coreutils (rm, mv) commands don't get the variable expanded, but the git command still does. Funny how those differ in interpretation.
It fails horribly. The git command still works (but doesn't in this case because the directory didn't get rm -rf'd first... but it's got the variable expanded correctly, glibc)
I took out the output squelching rm -rf and >/dev/null to demonstrate (otherwise it will just silently fail)
Code: Select all
[grogan@nicetry ~]$ ./PKGBUILD-get glibc
rm: missing operand
Try 'rm --help' for more information.
mv: missing destination file operand after 'glibc'
Try 'mv --help' for more information.
fatal: destination path 'glibc' already exists and is not an empty directory.Code: Select all
#! /bin/sh
PKG="$1"
rm -rf "$PKG"_old > /dev/null 2>&1
mv "$PKG" "$PKG"_old > /dev/null 2>&1
git clone https://gitlab.archlinux.org/archlinux/packaging/packages/"$PKG".gitSingle quotes and double quotes have to be used correctly too, for an example that comes to mind... the source array in a PKGBUILD. Arch would use single quotes for each element in the array, EXCEPT when variables have to be expanded. Thus, this doesn't work... it will literally try to use $pkgver
Code: Select all
source=('llvm-project-$pkgver-checkout.tar.gz' 'blah.whatever')Code: Select all
source=("llvm-project-$pkgver-checkout.tar.gz" 'blah.whatever')The moral of the story is, don't be lazy... quote your fucking variables!