Re: [PATCH 2/3] scripts/make-erofs.sh: Avoid calls to dirname

Alyssa Ross
2025-09-21T11:40:48Z

[-- Attachment #1: Type: text/plain, Size: 1020 bytes --]

Demi Marie Obenour <demiobenour@gmail.com> writes:

> Use builtin string manipulation instead.
>
> Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>

With a copyright header added:

Reviewed-by: Alyssa Ross <hi@alyssa.is>

> ---
> scripts/make-erofs.sh | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/make-erofs.sh b/scripts/make-erofs.sh
> index 82d37573ad0454e79becfddd05f93585df7b671c..ac62a65f53e0b6417b164f475a537960fc5203bc 100755
> --- a/scripts/make-erofs.sh
> +++ b/scripts/make-erofs.sh
> @@ -40,7 +40,13 @@ while read -r arg1; do
> continue
> fi
>
> - parent=$(dirname "$arg2")
> + # The below simple version of dirname(1) can only handle
> + # a subset of all paths, but this subset includes all of
> + # the ones passed in practice other than /.
> + case $arg2 in
> + (*/*) parent=${arg2%/*};;
> + (*) parent=.;;
> + esac
> mkdir -p -- "$root/$parent"
> cp -RT -- "$arg1" "$root/$arg2"
> done
>
> --
> 2.51.0

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 227 bytes --]