-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
159 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env bash | ||
|
||
function echo_nothing_or_fail() ( | ||
source "$DOROTHY/sources/stdinargs.bash" | ||
|
||
function help { | ||
cat <<-EOF >/dev/stderr | ||
ABOUT: | ||
If input is provided, fail. | ||
If no input was provided, success. | ||
USAGE: | ||
echo-nothing-or-fail [...options] [--] ...<input> | ||
echo-lines ...<input> | echo-nothing-or-fail [...options] | ||
OPTIONS: | ||
$(stdinargs_options_help --) | ||
EXAMPLE: | ||
# success cases | ||
echo-nothing-or-fail -- 'sup' | ||
echo 'sup' | echo-nothing-or-fail --stdin | ||
# exit status: 1 | ||
# failure cases, no stdin, no arguments | ||
echo-nothing-or-fail -- | ||
true | echo-nothing-or-fail --stdin | ||
# exit status: 0 | ||
EOF | ||
return 22 # EINVAL 22 Invalid argument | ||
} | ||
|
||
function on_input { | ||
return 1 # failure | ||
} | ||
|
||
function on_no_input { | ||
return 0 # success | ||
} | ||
|
||
stdinargs "$@" | ||
) | ||
|
||
# fire if invoked standalone | ||
if test "$0" = "${BASH_SOURCE[0]}"; then | ||
echo_nothing_or_fail "$@" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#!/usr/bin/env bash | ||
|
||
function fs_dequaratine() ( | ||
source "$DOROTHY/sources/bash.bash" | ||
|
||
# ===================================== | ||
# Arguments | ||
|
||
function help { | ||
cat <<-EOF >/dev/stderr | ||
ABOUT: | ||
Remove the quaratine flag from a path. | ||
USAGE: | ||
fs-dequarantine [--] ...<path> | ||
EOF | ||
if test "$#" -ne 0; then | ||
echo-error "$@" | ||
fi | ||
return 22 # EINVAL 22 Invalid argument | ||
} | ||
|
||
# process | ||
local item option_paths=() | ||
while test "$#" -ne 0; do | ||
item="$1" | ||
shift | ||
case "$item" in | ||
'--help' | '-h') help ;; | ||
'--') | ||
option_paths+=("$@") | ||
shift $# | ||
break | ||
;; | ||
'--'*) help "An unrecognised flag was provided: $item" ;; | ||
*) option_paths+=("$item") ;; | ||
esac | ||
done | ||
|
||
# check | ||
if test "${#option_paths[@]}" -eq 0; then | ||
help 'No <path>s were provided.' | ||
fi | ||
|
||
# ===================================== | ||
# Action | ||
|
||
if ! is-mac || command-missing xattr; then | ||
return 0 # not needed | ||
fi | ||
|
||
function disable_quarantine_on_path { | ||
local path="$1" output status cmd=('xattr') | ||
# https://apple.stackexchange.com/a/436677/15131 | ||
# option -r not recognized | ||
if test -d "$path"; then | ||
cmd+=('-dr') | ||
else | ||
cmd+=('-d') | ||
fi | ||
cmd+=('com.apple.quarantine' "$path") | ||
eval_capture --outputvar=output --statusvar=status -- "${cmd[@]}" | ||
if test "$status" -eq 0 -o "$output" = 'No such xattr: com.apple.quarantine'; then | ||
return 0 | ||
fi | ||
eval_capture --outputvar=output --statusvar=status -- sudo-helper -- "${cmd[@]}" | ||
if test "$status" -eq 0 -o "$output" = 'No such xattr: com.apple.quarantine'; then | ||
return 0 | ||
fi | ||
print_line "$output" >/dev/stderr | ||
return "$status" | ||
} | ||
|
||
local path | ||
for path in "${option_paths[@]}"; do | ||
disable_quarantine_on_path "$path" | ||
done | ||
) | ||
|
||
# fire if invoked standalone | ||
if test "$0" = "${BASH_SOURCE[0]}"; then | ||
fs_dequaratine "$@" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters