dot

packages and services management
Log | Files | Refs | README

commit 23f069f18fc85f82d05ddcf2fd8ca9814b579f62
parent a1621628d8c675b232ffb9e21a07e5be8fbfeb74
Author: Josuah Demangeon <josuah.demangeon@gandi.net>
Date:   Sat,  5 Aug 2017 16:59:00 +0200

shell/bin/sane-name: sanitize a name

Diffstat:
Ashell/bin/sane-name | 10++++++++++
1 file changed, 10 insertions(+), 0 deletions(-)

diff --git a/shell/bin/sane-name b/shell/bin/sane-name @@ -0,0 +1,10 @@ +# only keep '[:alnum:]', ',' and '.' and convert everyting else to '-' + +find . -depth | while IFS='' read -r path +do + dir=$(dirname "$path") + old=$(basename "$path") + new=$(printf %s "$old" | tr -c '[:alnum:],.' '-' | sed -r 's/-+/-/g') + + [ "$dir/$old" != "$dir/$new" ] && mv +done