Nah, that doesn't really work. Falling back to this method
This commit is contained in:
parent
b2eb1eabf0
commit
69cbb6f286
21
sx-open
21
sx-open
|
@ -11,7 +11,7 @@ handle_uri() {
|
||||||
local target="$1"
|
local target="$1"
|
||||||
|
|
||||||
for h in "${!uri_handlers[@]}"; do
|
for h in "${!uri_handlers[@]}"; do
|
||||||
grep -oE "${uri_handlers[${h}]}" <<< "$target" && {
|
grep -oE "${uri_handlers[${h}]}" &>/dev/null <<< "$target" && {
|
||||||
${h} "$target" &
|
${h} "$target" &
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
@ -20,15 +20,15 @@ handle_uri() {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
handle_file() {
|
handle_fs_target() {
|
||||||
local target="$1"
|
local target="$1"
|
||||||
|
|
||||||
[[ -f "$target" ]] || return 1
|
[[ -e "$target" ]] || return 1
|
||||||
|
|
||||||
target_mimetype=$(file -ib "$target")
|
target_mimetype=$(file -ib "$target")
|
||||||
|
|
||||||
for m in "${!mime_handlers[@]}"; do
|
for m in "${!mime_handlers[@]}"; do
|
||||||
grep -oE "${mime_handlers[${m}]}" <<< "$target_mimetype" && {
|
grep -oE "${mime_handlers[${m}]}" &>/dev/null <<< "$target_mimetype" && {
|
||||||
${m} "$target" &
|
${m} "$target" &
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
@ -38,9 +38,18 @@ handle_file() {
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
[[ "$1" ]] || { usage; exit; }
|
target="$1"
|
||||||
|
[[ "$target" ]] || { usage; exit; }
|
||||||
|
|
||||||
handle_file "$1" || handle_uri "$1"
|
if [[ -e "$target" ]]; then
|
||||||
|
handle_fs_target "$target"
|
||||||
|
else
|
||||||
|
handle_uri "$target"
|
||||||
|
fi
|
||||||
|
|
||||||
|
[[ "$?" -gt 0 ]] && {
|
||||||
|
echo "No handlers found for $target"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user