[Nix-dev] Re: [Nix-commits] SVN commit: nix - 12545 - eelco - in nixos/trunk: boot configuration helpers system

Nicolas Pierron nicolas.b.pierron at gmail.com
Fri Aug 8 19:25:22 CEST 2008


On Fri, Aug 8, 2008 at 19:07, Eelco Dolstra <e.dolstra at tudelft.nl> wrote:
> Modified: nixos/trunk/boot/boot-stage-1-init.sh
> ===================================================================
> --- nixos/trunk/boot/boot-stage-1-init.sh       2008-08-08 15:49:57 UTC (rev 12544)
> +++ nixos/trunk/boot/boot-stage-1-init.sh       2008-08-08 17:07:04 UTC (rev 12545)
>
> +# Poor man's `basename'.
> +basename() {
> +    local s="$1"
> +    set -- $(IFS=/; echo $s)
> +    local res
> +    while test $# != 0; do res=$1; shift; done
> +    echo $res
> +}
> +

Does this poor man miss shell substitution ?

basename(){
  local file="$1"
  file="${file%%/}" # remove trailing slash for directories
  echo "${file##*/}"
}

-- 
Nicolas Pierron
- If you are doing something twice then you should try to do it once.



More information about the nix-dev mailing list