Skip to content

Commit

Permalink
"clean" command.
Browse files Browse the repository at this point in the history
resolves #1
  • Loading branch information
alexhsamuel committed Aug 12, 2017
1 parent f07a903 commit 22414ee
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 9 additions & 1 deletion path-v3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,11 @@ _path-clean() {
_path-join-set "$varname" "${clean[@]}"
}

_path-clear() {
local varname="$1"
_path-join-set "$varname"
}

_path-help() {
echo 'Usage: path VARNAME [ COMMAND ... ]
Expand All @@ -233,6 +238,9 @@ _path-help() {
Moves item at position SRC of $VARNAME to position DST.
If DST is omitted, moves item at position SRC to the front of $VARNAME.
path VARNAME clear
Removes all path components.
path VARNAME clean [ --real ]
Removes the second and subsequent occurence of each component of $VARNAME.
With --real, components are compared based on actual file system identity,
Expand Down Expand Up @@ -261,7 +269,7 @@ path() {
+) command=add;;
mv) command=move;;
# Valid commands.
add|clean|in|move|prepend|remove|show);;
add|clean|clear|in|move|prepend|remove|show);;
# Anything else is invalid.
*)
echo "invalid command '$command'" >&2
Expand Down
10 changes: 9 additions & 1 deletion path.sh
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ _path-clean() {
_path-join-set "$varname" "${clean[@]}"
}

_path-clear() {
local varname="$1"
_path-join_set "$varname"
}

_path-help() {
echo 'Usage: path VARNAME [ COMMAND ... ]
Expand All @@ -224,6 +229,9 @@ _path-help() {
Moves item at position SRC of $VARNAME to position DST.
If DST is omitted, moves item at position SRC to the front of $VARNAME.
path VARNAME clear
Removes all path components.
path VARNAME clean [ --real ]
Removes the second and subsequent occurence of each component of $VARNAME.
With --real, components are compared based on actual file system identity,
Expand Down Expand Up @@ -265,7 +273,7 @@ path() {
+) command=add;;
mv) command=move;;
# Valid commands.
add|clean|in|move|prepend|remove|show);;
add|clean|clear|in|move|prepend|remove|show);;
# Anything else is invalid.
*)
echo "invalid command '$command'" >&2
Expand Down

0 comments on commit 22414ee

Please sign in to comment.