From: Harald Hoyer <harald-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: Michal Soltys <soltys-R61QfzASbfY@public.gmane.org>
Cc: initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 5/4] dracut-functions: conv/normalize minor corrections
Date: Mon, 10 Oct 2011 11:57:47 +0200 [thread overview]
Message-ID: <4E92C19B.4000307@redhat.com> (raw)
In-Reply-To: <1318026050-5891-2-git-send-email-soltys-R61QfzASbfY@public.gmane.org>
On 08.10.2011 00:20, Michal Soltys wrote:
> mostly with reference to earlier commit:
>
> - bash doesn't need unsetting locals
> - make normalize_path() a bit faster, also make sure we remove all
> trailing slashes
> - normalize paths before tests
>
> Signed-off-by: Michal Soltys <soltys-R61QfzASbfY@public.gmane.org>
> ---
> dracut-functions | 22 ++++++++++------------
> 1 files changed, 10 insertions(+), 12 deletions(-)
>
> diff --git a/dracut-functions b/dracut-functions
> index 12dfa70..ce593c9 100755
> --- a/dracut-functions
> +++ b/dracut-functions
> @@ -83,31 +83,29 @@ print_vars() {
> }
>
> normalize_path() {
> - p=$1
> - while [[ ${p#*//*} != $p ]]; do
> - p=${p/\/\///}
> - done
> - echo $p
> + shopt -q -s extglob
> + set -- "${1//+(\/)//}"
> + shopt -q -u extglob
> + echo "${1%/}"
> }
>
> convert_abs_rel() {
> - local __current __absolute __abssize __cursize __newpath="" __oldifs
> - local -i __i __level=0
> + local __current __absolute __abssize __cursize __newpath __oldifs
> + local -i __i __level
> # PS4='${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): ';
>
> + set -- "$(normalize_path "$1")" "$(normalize_path "$2")"
> +
> # corner case #1 - self looping link
> [[ "$1" == "$2" ]] && { echo "${1##*/}"; return; }
>
> # corner case #2 - own dir link
> [[ "${1%/*}" == "$2" ]] && { echo "."; return; }
>
> - __current=$(normalize_path "$1")
> - __absolute=$(normalize_path "$2")
> -
> __oldifs="$IFS"
> IFS="/"
> - __current=($__current)
> - __absolute=($__absolute)
> + __current=($1)
> + __absolute=($2)
> IFS="$__oldifs"
>
> __abssize=${#__absolute[@]}
pushed all 5
prev parent reply other threads:[~2011-10-10 9:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-30 21:45 [PATCH 0/4] options to configure fs-lib (fsck) and two unrelated fixes Michal Soltys
2011-10-07 7:49 ` WANG Cong
2011-10-07 20:06 ` Michal Soltys
[not found] ` <4E8F5BB9.2090405-R61QfzASbfY@public.gmane.org>
2011-10-08 11:44 ` Américo Wang
[not found] ` <4E86385C.6040706-R61QfzASbfY@public.gmane.org>
2011-10-07 20:23 ` [PATCH 1/4] convert_abs_rel() fixups Michal Soltys
2011-10-07 20:23 ` [PATCH 2/4] dracut.8: add missing lvmconf info Michal Soltys
2011-10-07 20:23 ` [PATCH 3/4] fs-lib: add ability to choose fsck tools Michal Soltys
2011-10-07 20:23 ` [PATCH 4/4] manuals: add info about fs-lib (fsck) configuration Michal Soltys
2011-10-07 22:20 ` minor corrections Michal Soltys
2011-10-07 22:20 ` [PATCH 5/4] dracut-functions: conv/normalize " Michal Soltys
[not found] ` <1318026050-5891-2-git-send-email-soltys-R61QfzASbfY@public.gmane.org>
2011-10-10 9:57 ` Harald Hoyer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E92C19B.4000307@redhat.com \
--to=harald-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
--cc=initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=soltys-R61QfzASbfY@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.