Remove useless curly braces - dossier - console collection manager
DIR Log
DIR Files
DIR Refs
DIR Tags
DIR README
DIR LICENSE
---
DIR commit 7ea0cf799e0f6e790535f595fcb3c24951e3b284
DIR parent af4d6f9504d0bc8395b6bbd5cafadadbbd526fa2
HTML Author: Solene Rapenne <solene@perso.pw>
Date: Tue, 24 Jul 2018 10:51:04 +0200
Remove useless curly braces
Diffstat:
M dossier | 33 +++++++++++++++----------------
1 file changed, 16 insertions(+), 17 deletions(-)
---
DIR diff --git a/dossier b/dossier
@@ -24,7 +24,7 @@ exists() {
# displays the values of an identifier
# $1 identifier
show() {
- cd "${REPO}"
+ cd "$REPO"
if exists "$1"
then
SEEN=0
@@ -37,7 +37,7 @@ show() {
printf "%s:\n" "$1"
SEEN=1
fi
- printf "%15s: %s\n" ${attribute} "$(cat "${attribute}/${1}")"
+ printf "%15s: %s\n" "$attribute" "$(cat "${attribute}/${1}")"
fi
done
exit 0
@@ -50,7 +50,7 @@ show() {
# export the data in csv format "data","data","data"
# we assume it'll works with the dataset
export_csv() {
- cd "${REPO}"
+ cd "$REPO"
# display header
printf '"identifier",'
@@ -79,7 +79,7 @@ export_csv() {
# delete identifier from attributes
# $1 identifier
delete() {
- cd "${REPO}"
+ cd "$REPO"
SEEN=0
for attribute in *
do
@@ -87,7 +87,7 @@ delete() {
then
git rm "${attribute}/${1}"
git commit -m "Delete ${attribute} ${1}" "${attribute}/${1}"
- rmdir "${attribute}" 2> /dev/null
+ rmdir "$attribute" 2> /dev/null
SEEN=1
fi
done
@@ -104,7 +104,7 @@ delete() {
# displays list of identifiers
show_list() {
- cd "${REPO}"
+ cd "$REPO"
find . -name '.git' -prune -o -type f -print | cut -d '/' -f 3 | sort | uniq -c | \
awk '{ for(i=2;i<=NF;i=i+1) { printf "%s ", $i }
printf "(%i)\n", $1
@@ -114,7 +114,7 @@ show_list() {
# displays attributes used
show_attributes() {
- cd "${REPO}"
+ cd "$REPO"
find . -name '.git' -prune -o -type f -print | cut -d '/' -f 2 | sort | uniq -c | \
awk '{ for(i=2;i<=NF;i=i+1) { printf "%s ", $i }
printf "(%i)\n", $1
@@ -162,7 +162,7 @@ search_value() {
shift 2
if [ ! -d "$ATTRIBUTE" ]
then
- printf 'The attribute %s do not exists\n' "${ATTRIBUTE}"
+ printf 'The attribute %s do not exists\n' "$ATTRIBUTE"
exit 5
fi
grep -rl "$VALUE" "$ATTRIBUTE" | cut -d '/' -f 2 >> "$RESULT"
@@ -217,17 +217,17 @@ usage() {
switch() {
if [ ! -L "${REPOSITORY}/${1}" ]
then
- printf 'Collection %s is not registered\n' "${1}"
+ printf 'Collection %s is not registered\n' "$1"
exit 9
else
- printf 'Switching to collection %s\n' "${1}"
+ printf 'Switching to collection %s\n' "$1"
printf 'CONTEXT=%s\n' $1 > "${REPOSITORY}/current"
exit $?
fi
}
collections() {
- ls "${REPOSITORY}" | grep -v 'current' | sed "s/^${CONTEXT}$/& */"
+ ls "$REPOSITORY" | grep -v 'current' | sed "s/^${CONTEXT}$/& */"
exit 0
}
@@ -235,18 +235,17 @@ collections() {
# $1 absolute path to collection
# $2 name of collection
register() {
- set -x
- if [ -d "${1}" ]
+ if [ -d "$1" ]
then
- if ! expr "${1}" : '^/'
+ if ! expr "$1" : '^/'
then
- printf 'Aborting, the path of the collection must be an absolute path. %s is not valid\n' "${1}"
+ printf 'Aborting, the path of the collection must be an absolute path. %s is not valid\n' "$1"
fi
test -L "${REPOSITORY}/${2}" && rm "${REPOSITORY}/${2}"
- ln -s "${1}" "${REPOSITORY}/${2}"
+ ln -s "$1" "${REPOSITORY}/${2}"
exit 0
else
- printf 'Aborting, %s is not a directory\n' "${2}"
+ printf 'Aborting, %s is not a directory\n' "$2"
exit 8
fi
}