Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Nedeľa, 18. máj 2025

Súbor: [Platon] / platos / _scripts / path-cleanup (stiahnutie)

Revízia 1.2, Sat Feb 22 03:13:50 2014 UTC (11 years, 2 months ago) by nepto


Zmeny od 1.1: +2 -2 [lines]

Shell changed to bash, because something was not working properly

#!/bin/bash

#
# _scripts/path-cleanup
#
# Developed by Lubomir Host 'rajo' <rajo AT platon.sk>
# Copyright (c) 2005 Platon SDG, http://platon.sk/
# Licensed under terms of GNU General Public License.
# All rights reserved.
#
# Changelog:
# 2005-06-11 - created
#

# $Platon: Platon.SK/office/_scripts/path-cleanup,v 1.1 2005-06-11 01:46:58 rajo Exp $

#
# Make cleanup in path:
#
# 1. - remove duplicated  '/././'
# 2. - remove duplicated   '//'
# 2. - remove directories 'a/b/../c/'  -->  'a/c/'

# comment out next line for debugging
DEBUG=":"

# uncomment next line and progress bar is turned off
#PROGRESSBAR=":"

OUT="/dev/stderr"

REGEXP='s%/\(\./\)\+%/%g; s%/\+%/%g; s%\([^/]\+\)/\.\./%%g; s%/\.\?$%%g;'

make_clanup()
{ # {{{
    file="$1"
    $DEBUG echo "--> Starting with '$file'" > $OUT
    $PROGRESSBAR echo -n "Cleaning path ." > $OUT
    old="$file"
    file=`echo "$file" | sed -e "$REGEXP"`
    $DEBUG echo "    first iter: '$file'" > $OUT
    while [ "x$old" != "x$file" ]; do
        old="$file"
        file=`echo "$file" | sed -e "$REGEXP"`
        $DEBUG echo "          iter: '$file'" > $OUT
        $PROGRESSBAR echo -n "." > $OUT
    done
    $PROGRESSBAR echo " done." > $OUT

    echo "$file"

} # }}}

for filename in $*; do
    make_clanup "$filename"
done


Platon Group <platon@platon.sk> http://platon.sk/
Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok