From 176f5e0c0e6730908f35aebf60a1e33f8735a025 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sun, 8 Aug 2010 22:51:46 +0200 Subject: add 3 more files Signed-off-by: Florian Pritz --- shop | 157 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100755 shop (limited to 'shop') diff --git a/shop b/shop new file mode 100755 index 0000000..c2e01fe --- /dev/null +++ b/shop @@ -0,0 +1,157 @@ +#!/bin/bash +# +# shop - Show Permissions at all levels of a given path +# +# With `tree(1)` you start at a trunk and show all leaves that +# originate from that trunk, optionally showing permissions. +# `shop` starts at a leaf and shows the permissions back to a +# trunk. +# +# CREATED: 2009-09-03 17:30 +# MODIFIED: 2009-11-17 11:05 + +_NAME=$(basename $0) +_VERSION=1.0 + +# DEFAULTS +unset octal # use text mode instead of octal mode +level=-1 # traverse all the way up to / +trunk='/' # traverse all the way up to / +pad=17 # padding for pathname + +usage() { + cat < /dev/null + elif [ $level -eq 0 ]; then + break; + fi + done + + # display the permissions for each level + while [ "$PWD" != "$start_dir" ]; do + _shop "$PWD" + popd &> /dev/null + done + _shop "$PWD" + + # leaf was a file, run _shop on this file as well + if [ $file_arg ]; then + _shop "${PWD}/$(basename -- "$arg")" + else + cd .. || return 1 + fi + + # user passed multiple leafs, separate output for each leaf + if [ $# -gt 1 ]; then + echo + fi + + shift + arg="$1" + done +} + +declare -a args +until [ -z "$1" ]; do + case "$1" in + -L|--level) level="$2" + shift 2 + ;; + + -o|--octal) octal=1 + shift + ;; + + -t|--trunk) trunk="$(readlink -f $2)" + shift 2 + ;; + + -p|--pad) pad="$2" + shift 2 + ;; + + -h|--help) usage + exit + ;; + + --version) echo "$_NAME v$_VERSION" + exit + ;; + + --) shift + args=( "${args[@]}" "$@" ) + break + ;; + + -*) echo -e "$_NAME: unknown option: $1\n" + usage + exit + ;; + + *) args[${#args[*]}]="$1" + shift + ;; + esac +done + +main "${args[@]}" -- cgit v1.2.3-24-g4f1b