๐Ÿ“ฆโž”๐Ÿฆ‹ Store and retrieve files on the Atmosphere
35
fork

Configure Feed

Select the types of activity you want to include in your feed.

[#16] fix/ignore various shellcheck issues

Ducky 4975caff 4f23e164

+101 -67
+1 -1
atfile-install.sh
··· 38 38 v_major="$(printf "%04d\n" "$(echo "$version" | cut -d "." -f 1)")" 39 39 v_minor="$(printf "%04d\n" "$(echo "$version" | cut -d "." -f 2)")" 40 40 v_rev="$(printf "%04d\n" "$(echo "$version" | cut -d "." -f 3)")" 41 - echo "$(echo ${v_major}${v_minor}${v_rev} | sed 's/^0*//')" 41 + echo "$(echo "${v_major}${v_minor}${v_rev}" | sed 's/^0*//')" 42 42 } 43 43 44 44 function xrpc_get() {
+1
atfile.sh
··· 69 69 fi 70 70 71 71 git describe --exact-match --tags > /dev/null 2>&1 72 + # shellcheck disable=SC2181 72 73 [[ $? != 0 ]] && version+="+git.$(git rev-parse --short HEAD)" 73 74 74 75 # BUG: Clobbers variables from config file
+20 -9
src/commands/old_cmds.sh
··· 32 32 json_output="{\"blobs\":[" 33 33 fi 34 34 35 - while IFS=$"\n" read -r c; do 36 - cid="$(echo $c | jq -r ".")" 35 + while IFS=$'\n' read -r c; do 36 + cid="$(echo "$c" | jq -r ".")" 37 37 blob_uri="$(atfile.util.build_blob_uri "$_username" "$cid")" 38 38 last_cid="$cid" 39 39 ((record_count++)) ··· 127 127 downloaded_file="$(atfile.util.build_out_filename "$key" "$file_name")" 128 128 129 129 curl -H "User-Agent: $(atfile.util.get_uas)" --silent "$blob_uri" -o "$downloaded_file" 130 + # shellcheck disable=SC2181 130 131 [[ $? != 0 ]] && success=0 131 132 fi 132 133 ··· 135 136 136 137 gpg --quiet --output "$new_downloaded_file" --decrypt "$downloaded_file" 137 138 139 + # shellcheck disable=SC2181 138 140 if [[ $? != 0 ]]; then 139 141 success=0 140 142 else ··· 169 171 170 172 if [[ $success == 1 ]]; then 171 173 file_type="$(echo "$record" | jq -r '.value.file.mimeType')" 172 - did="$(echo $record | jq -r ".uri" | cut -d "/" -f 3)" 174 + did="$(echo "$record" | jq -r ".uri" | cut -d "/" -f 3)" 173 175 key="$(atfile.util.get_rkey_from_at_uri "$(echo "$record" | jq -r ".uri")")" 174 176 blob_uri="$(atfile.util.build_blob_uri "$did" "$(echo "$record" | jq -r ".value.blob.ref.\"\$link\"")")" 175 177 cdn_uri="$(atfile.util.get_cdn_uri "$did" "$(echo "$record" | jq -r ".value.blob.ref.\"\$link\"")" "$file_type")" ··· 180 182 # shellcheck disable=SC2154 181 183 atfile.say.debug "Getting record...\nโ†ณ NSID: $_nsid_lock\nโ†ณ Repo: $_username\nโ†ณ Key: $key" 182 184 locked_record="$(com.atproto.repo.getRecord "$_username" "$_nsid_lock" "$key")" 185 + # shellcheck disable=SC2181 183 186 if [[ $? == 0 ]] && [[ -n "$locked_record" ]]; then 184 187 if [[ $(echo "$locked_record" | jq -r ".value.lock") == true ]]; then 185 188 locked="$(atfile.util.get_yn 1)" ··· 237 240 else 238 241 case $finger_type in 239 242 "browser") 240 - finger_browser_uas="$(echo $record | jq -r ".value.finger.userAgent")" 243 + finger_browser_uas="$(echo "$record" | jq -r ".value.finger.userAgent")" 241 244 242 245 [[ -z $finger_browser_uas || $finger_browser_uas == "null" ]] && finger_browser_uas="(Unknown)" 243 246 ··· 291 294 handler="$2" 292 295 293 296 function atfile.invoke.handle_atfile.is_temp_file_needed() { 294 - handler="$(echo $1 | sed s/.desktop$//g)" 297 + handler="$(echo "$1" | sed s/.desktop$//g)" 295 298 type="$2" 296 299 297 300 handlers=( ··· 340 343 atfile.say.debug "Handler manually set to '$handler'" 341 344 fi 342 345 346 + # shellcheck disable=SC2319 347 + # shellcheck disable=SC2181 343 348 if [[ -n $handler ]] || [[ $? != 0 ]]; then 344 - atfile.say.debug "Opening '$key' ($file_type) with '$(echo $handler | sed s/.desktop$//g)'..." 349 + atfile.say.debug "Opening '$key' ($file_type) with '$(echo "$handler" | sed s/.desktop$//g)'..." 345 350 346 351 # HACK: Some apps don't like http(s)://; we'll need to handle these 347 352 if [[ $(atfile.invoke.handle_atfile.is_temp_file_needed "$handler" "$file_type") == 1 ]]; then ··· 438 443 json_output="{\"uploads\":[" 439 444 fi 440 445 441 - while IFS=$"\n" read -r c; do 442 - key=$(atfile.util.get_rkey_from_at_uri "$(echo $c | jq -r ".uri")") 446 + while IFS=$'\n' read -r c; do 447 + key=$(atfile.util.get_rkey_from_at_uri "$(echo "$c" | jq -r ".uri")") 443 448 name="$(echo "$c" | jq -r '.value.file.name')" 444 449 type_emoji="$(atfile.util.get_file_type_emoji "$(echo "$c" | jq -r '.value.file.mimeType')")" 445 450 last_key="$key" ··· 529 534 [[ -z "$record" ]] && atfile.die "<record> not set" 530 535 531 536 record_json="$(echo "$record" | jq)" 537 + # shellcheck disable=SC2181 532 538 [[ $? != 0 ]] && atfile.die "Invalid JSON" 533 539 534 540 com.atproto.repo.createRecord "$_username" "$collection" "$record_json" | jq ··· 583 589 [[ -z "$record" ]] && atfile.die "<record> not set" 584 590 585 591 record_json="$(echo "$record" | jq)" 592 + # shellcheck disable=SC2181 586 593 [[ $? != 0 ]] && atfile.die "Invalid JSON" 587 594 588 595 if [[ "$key" == at:* ]]; then ··· 612 619 file_type="$(echo "$record" | jq -r '.value.file.mimeType')" 613 620 614 621 curl -H "$(atfile.util.get_uas)" -s -L "$blob_uri" --output - 622 + # shellcheck disable=SC2181 615 623 [[ $? != 0 ]] && error="?" 616 624 fi 617 625 ··· 627 635 [[ $_os == "haiku" ]] && atfile.die "Not available on Haiku" 628 636 [[ $_os == "macos" ]] && atfile.die "Not available on macOS\nThink you could help? See: https://tangled.sh/@zio.sh/atfile/issues/9" 629 637 638 + uid="$(id -u)" 630 639 if [[ $uid == 0 ]]; then 631 640 desktop_dir="/usr/local/share/applications" 632 641 mime_dir="/usr/local/share/mime" ··· 690 699 [[ $_output_json == 0 ]] && echo -e "Encrypting '$file_crypt'..." 691 700 gpg --yes --quiet --recipient "$recipient" --output "$file_crypt" --encrypt "$file" 692 701 702 + # shellcheck disable=SC2181 693 703 if [[ $? == 0 ]]; then 694 704 file="$file_crypt" 695 705 else ··· 711 721 ;; 712 722 "haiku") 713 723 haiku_file_attr="$(catattr BEOS:TYPE "$file" 2> /dev/null)" 724 + # shellcheck disable=SC2181 714 725 [[ $? == 0 ]] && file_type="$(echo "$haiku_file_attr" | cut -d ":" -f 3 | xargs)" 715 726 716 727 file_date="$(atfile.util.get_date "$(stat -c '%y' "$file")")" ··· 787 798 788 799 if [[ -z "$error" ]]; then 789 800 unset recipient_key 790 - blob_uri="$(atfile.util.build_blob_uri "$(echo "$record" | jq -r ".uri" | cut -d "/" -f 3)" "$(echo $blob | jq -r ".ref.\"\$link\"")")" 801 + blob_uri="$(atfile.util.build_blob_uri "$(echo "$record" | jq -r ".uri" | cut -d "/" -f 3)" "$(echo "$blob" | jq -r ".ref.\"\$link\"")")" 791 802 key="$(atfile.util.get_rkey_from_at_uri "$(echo "$record" | jq -r ".uri")")" 792 803 793 804 if [[ -n "$recipient" ]]; then
+22 -20
src/commands/release.sh
··· 29 29 parsed_version="$(atfile.util.parse_version "$_version")" 30 30 version_record_id="atfile-$parsed_version" 31 31 32 - atfile.say "Building..." 32 + test_error_count=0 33 + test_info_count=0 34 + test_style_count=0 35 + test_warning_count=0 36 + test_ignore_count=0 37 + 38 + atfile.say "โš’๏ธ Building..." 33 39 40 + echo "โ†ณ Creating '$dist_file'..." 34 41 mkdir -p "$dist_dir" 35 - 36 - echo "โ†ณ Compiling '$dist_file'..." 37 42 echo "#!/usr/bin/env bash" > "$dist_path" 38 43 44 + echo "โ†ณ Generating header..." 39 45 echo -e "\n# ATFile <https://tangled.sh/@zio.sh/atfile> 40 46 # --- 41 47 # Version: $_version ··· 50 56 do 51 57 if [[ "$s" != *"/src/commands/release.sh" ]]; then 52 58 if [[ -f "$s" ]]; then 53 - echo " โ†ณ Adding: $s" 59 + echo "โ†ณ Adding: $s" 54 60 55 61 while IFS="" read -r line 56 62 do ··· 65 71 66 72 if [[ $line == *"# shellcheck disable"* ]]; then 67 73 include_line=1 74 + (( test_ignore_count++ )) 68 75 fi 69 - 70 76 71 77 if [[ $include_line == 1 ]]; then 72 78 if [[ $line == *"{:"* && $line == *":}"* ]]; then ··· 91 97 92 98 echo "$dist_path" 93 99 94 - echo "Testing..." 100 + echo "๐Ÿงช Testing..." 95 101 shellcheck_output="$(shellcheck --format=json "$dist_path" 2>&1)" 96 102 97 - test_error_count=0 98 - test_info_count=0 99 - test_style_count=0 100 - test_warning_count=0 101 - 102 103 while read -r item; do 103 104 code="$(echo "$item" | jq -r '.code')" 104 105 col="$(echo "$item" | jq -r '.column')" ··· 118 119 119 120 test_total_count=$(( test_error_count + test_info_count + test_style_count + test_warning_count )) 120 121 121 - echo -e "Built: $_version 122 + echo -e "---\nโœ… Built: $_version 122 123 โ†ณ Path: ./$dist_path_relative 123 124 โ†ณ Check: $checksum 124 125 โ†ณ Size: $(atfile.util.get_file_size_pretty "$(stat -c %s "$dist_path")") 125 126 โ†ณ Lines: $(atfile.util.fmt_int "$(wc -l < "$dist_path")") 126 127 โ†ณ Issues: $(atfile.util.fmt_int "$test_total_count") 127 - โ†ณ Error: $(atfile.util.fmt_int "$test_error_count") 128 - โ†ณ Warn: $(atfile.util.fmt_int "$test_warning_count") 129 - โ†ณ Info: $(atfile.util.fmt_int "$test_info_count") 130 - โ†ณ Style: $(atfile.util.fmt_int "$test_style_count") 128 + โ†ณ Error: $(atfile.util.fmt_int "$test_error_count") 129 + โ†ณ Warning: $(atfile.util.fmt_int "$test_warning_count") 130 + โ†ณ Info: $(atfile.util.fmt_int "$test_info_count") 131 + โ†ณ Style: $(atfile.util.fmt_int "$test_style_count") 132 + โ†ณ Ignored: $(atfile.util.fmt_int "$test_ignore_count") 131 133 โ†ณ ID: $id" 132 134 133 135 chmod +x "$dist_path" ··· 138 140 atfile.die "Unable to publish ($test_error_count errors detected)" 139 141 fi 140 142 141 - echo "---" 143 + atfile.say "---\nโœจ Updating..." 142 144 atfile.auth "$_dist_username" "$_dist_password" 143 145 [[ $_version == *"+"* ]] && atfile.die "Cannot publish a Git version ($_version)" 144 146 145 - atfile.say "Uploading '$dist_path'..." 147 + atfile.say "โ†ณ Uploading '$dist_path'..." 146 148 atfile.invoke.upload "$dist_path" "" "$version_record_id" 149 + # shellcheck disable=SC2181 147 150 [[ $? != 0 ]] && atfile.die "Unable to upload '$dist_path'" 148 - echo "---" 149 151 150 152 latest_release_record="{ 151 153 \"version\": \"$_version\", ··· 155 157 \"checksum\": \"$checksum\" 156 158 }" 157 159 158 - atfile.say "Updating latest record to $_version..." 160 + atfile.say "โ†ณ Bumping current version..." 159 161 # shellcheck disable=SC2154 160 162 atfile.invoke.manage_record put "at://$_username/self.atfile.latest/self" "$latest_release_record" &> /dev/null 161 163 fi
+1 -1
src/commands/resolve.sh
··· 76 76 atfile.say " $i" 77 77 fi 78 78 79 - first_alias="$a" 79 + first_alias="${a[0]}" 80 80 done 81 81 done <<< "$aliases" 82 82
+1 -1
src/commands/something_broke.sh
··· 65 65 โ†ณ UAS: $(atfile.util.get_uas) 66 66 โ†ณ Path: $_prog_path 67 67 Variables 68 - $(atfile.something_broke.print_envvar "DEBUG" $_debug_default) 68 + $(atfile.something_broke.print_envvar "DEBUG" "$_debug_default") 69 69 $(atfile.something_broke.print_envvar "DEVEL") 70 70 $(atfile.something_broke.print_envvar "DEVEL_DIR") 71 71 $(atfile.something_broke.print_envvar "DEVEL_ENTRY")
+9 -3
src/commands/update.sh
··· 45 45 latest_version="$(echo "$latest_release_record" | jq -r '.value.version')" 46 46 latest_version_commit="$(echo "$latest_release_record" | jq -r '.value.commit')" 47 47 latest_version_date="$(echo "$latest_release_record" | jq -r '.value.releasedAt')" 48 - parsed_latest_version="$(atfile.util.parse_version $latest_version)" 49 - parsed_running_version="$(atfile.util.parse_version $_version)" 48 + parsed_latest_version="$(atfile.util.parse_version "$latest_version")" 49 + parsed_running_version="$(atfile.util.parse_version "$_version")" 50 50 latest_version_record_id="atfile-$parsed_latest_version" 51 51 update_available=0 52 52 ··· 65 65 66 66 echo "---" 67 67 if [[ $_os == "haiku" ]]; then 68 + # shellcheck disable=SC2154 68 69 atfile.say "Update available ($latest_version)\nโ†ณ Run \`$_prog update\` to update" # BUG: Haiku Terminal has issues with emojis 69 70 else 70 71 atfile.say "๐Ÿ˜Ž Update available ($latest_version)\n โ†ณ Run \`$_prog update\` to update" ··· 86 87 87 88 atfile.say.debug "Touching temporary path ($temp_updated_path)..." 88 89 touch "$temp_updated_path" 90 + # shellcheck disable=SC2181 89 91 [[ $? != 0 ]] && atfile.die "Unable to create temporary file (do you have permission?)" 90 92 91 93 atfile.say.debug "Getting blob URL for $latest_version ($latest_version_record_id)..." 92 - blob_url="$(atfile.invoke.get_url $latest_version_record_id)" 94 + blob_url="$(atfile.invoke.get_url "$latest_version_record_id")" 95 + # shellcheck disable=SC2181 93 96 [[ $? != 0 ]] && atfile.die "Unable to get blob URL" 94 97 95 98 atfile.say.debug "Downloading latest release..." 96 99 curl -H "User-Agent: $(atfile.util.get_uas)" -s -o "$temp_updated_path" "$blob_url" 100 + # shellcheck disable=SC2181 97 101 if [[ $? == 0 ]]; then 102 + # shellcheck disable=SC2154 98 103 mv "$temp_updated_path" "$_prog_path" 104 + # shellcheck disable=SC2181 99 105 if [[ $? != 0 ]]; then 100 106 atfile.die "Unable to update (do you have permission?)" 101 107 else
+2 -2
src/entry.sh
··· 219 219 220 220 if [[ $is_os_supported == 0 ]]; then 221 221 if [[ $_skip_unsupported_os_warn == 0 ]]; then 222 - atfile.die "Unsupported OS ($(echo $_os | sed s/unknown-//g))\nโ†ณ Set ${_envvar_prefix}_SKIP_UNSUPPORTED_OS_WARN=1 to ignore" 222 + atfile.die "Unsupported OS ($(echo "$_os" | sed s/unknown-//g))\nโ†ณ Set ${_envvar_prefix}_SKIP_UNSUPPORTED_OS_WARN=1 to ignore" 223 223 else 224 224 atfile.say.debug "Skipping unsupported OS warning\nโ†ณ ${_envvar_prefix}_SKIP_UNSUPPORTED_OS_WARN is set ($_skip_unsupported_os_warn)" 225 225 fi ··· 241 241 242 242 atfile.say.debug "Checking required programs..." 243 243 atfile.util.check_prog "curl" "https://curl.se" 244 - [[ $os != "haiku" && $os != "solaris" ]] && atfile.util.check_prog "file" "https://www.darwinsys.com/file" 244 + [[ $_os != "haiku" && $_os != "solaris" ]] && atfile.util.check_prog "file" "https://www.darwinsys.com/file" 245 245 atfile.util.check_prog "jq" "$_prog_hint_jq" 246 246 [[ $_skip_ni_md5sum == 0 ]] && atfile.util.check_prog "md5sum" "" "${_envvar_prefix}_SKIP_NI_MD5SUM" 247 247
+2 -1
src/lexi/blue_zio_atfile.sh
··· 187 187 \"gps\": { 188 188 \"alt\": $gps_alt, 189 189 \"lat\": $gps_lat, 190 - \"long\": "$gps_long" 190 + \"long\": $gps_long 191 191 }, 192 192 \"title\": \"$title\", 193 193 \"video\": [ $video ] ··· 211 211 unset machine_id 212 212 unset machine_os 213 213 214 + # shellcheck disable=SC2154 214 215 if [[ $_enable_fingerprint == 1 ]]; then 215 216 machine_id_file="/etc/machine-id" 216 217 os_release_file="/etc/os-release"
+3 -3
src/shared/cache.sh
··· 1 1 #!/usr/bin/env bash 2 2 3 3 function atfile.cache.del() { 4 - key="$(atfile.util.get_cache_path $1)" 4 + key="$(atfile.util.get_cache_path "$1")" 5 5 [[ -f "$key" ]] && rm "$key" 6 6 } 7 7 8 8 function atfile.cache.get() { 9 - key="$(atfile.util.get_cache_path $1)" 9 + key="$(atfile.util.get_cache_path "$1")" 10 10 [[ -f "$key" ]] && cat "$key" 11 11 } 12 12 13 13 function atfile.cache.set() { 14 - key="$(atfile.util.get_cache_path $1)" 14 + key="$(atfile.util.get_cache_path "$1")" 15 15 value="$2" 16 16 17 17 # shellcheck disable=SC2154
+2 -1
src/shared/http.sh
··· 56 56 57 57 atfile.say.debug "$uri\nโ†ณ $file" "POST: " 58 58 59 - curl -s -X POST $_server/xrpc/$lexi \ 59 + # shellcheck disable=SC2154 60 + curl -s -X POST "$_server/xrpc/$lexi" \ 60 61 -H "$auth" \ 61 62 -H "Content-Type: $type" \ 62 63 -H "User-Agent: $(atfile.util.get_uas)" \
+2 -2
src/shared/say.sh
··· 40 40 fi 41 41 fi 42 42 43 - message="$(echo "$message" | sed -e "s|\\\n|\\\n$(atfile.util.repeat_char " " $prefix_length)|g")" 43 + message="$(echo "$message" | sed -e "s|\\\n|\\\n$(atfile.util.repeat_char " " "$prefix_length")|g")" 44 44 45 45 echo -n -e "${prefix}${color_message}$message\033[0m${suffix}" 46 46 } ··· 64 64 function atfile.say.inline() { 65 65 message="$1" 66 66 color="$2" 67 - atfile.say "$message" "" "" $color "" "\\" 67 + atfile.say "$message" "" "" "$color" "" "\\" 68 68 }
+33 -21
src/shared/util.sh
··· 37 37 download_hint="$2" 38 38 skip_hint="$3" 39 39 40 - if ! [ -x "$(command -v $command)" ]; then 40 + if ! [ -x "$(command -v "$command")" ]; then 41 41 message="'$command' not installed" 42 42 43 43 if [[ -n "$download_hint" ]]; then ··· 61 61 } 62 62 63 63 function atfile.util.check_prog_optional_metadata() { 64 + # shellcheck disable=SC2154 64 65 [[ $_skip_ni_exiftool == 0 ]] && atfile.util.check_prog "exiftool" "https://exiftool.org" "${_envvar_prefix}_SKIP_NI_EXIFTOOL" 66 + # shellcheck disable=SC2154 65 67 [[ $_skip_ni_mediainfo == 0 ]] && atfile.util.check_prog "mediainfo" "https://mediaarea.net/en/MediaInfo" "${_envvar_prefix}_SKIP_NI_MEDIAINFO" 66 68 } 67 69 ··· 70 72 71 73 if ! [[ -d $dir ]]; then 72 74 mkdir -p "$dir" 75 + # shellcheck disable=SC2181 73 76 [[ $? != 0 ]] && atfile.die "Unable to create directory '$dir'" 74 77 fi 75 78 } ··· 81 84 function atfile.util.get_app_url_for_at_uri() { 82 85 uri="$1" 83 86 84 - actor="$(echo $uri | cut -d / -f 3)" 85 - collection="$(echo $uri | cut -d / -f 4)" 86 - rkey="$(echo $uri | cut -d / -f 5)" 87 + actor="$(echo "$uri" | cut -d / -f 3)" 88 + collection="$(echo "$uri" | cut -d / -f 4)" 89 + rkey="$(echo "$uri" | cut -d / -f 5)" 87 90 88 91 ignore_url_validation=0 89 92 resolved_actor="$(atfile.util.resolve_identity "$actor")" ··· 94 97 unset actor_pds 95 98 unset resolved_url 96 99 100 + # shellcheck disable=SC2181 97 101 if [[ $? == 0 ]]; then 98 102 actor="$(echo "$resolved_actor" | cut -d "|" -f 1)" 99 103 actor_handle="$(echo "$resolved_actor" | cut -d "|" -f 3 | cut -d "/" -f 3)" ··· 172 176 } 173 177 174 178 function atfile.util.get_cache_path() { 179 + # shellcheck disable=SC2154 175 180 echo "$_path_cache/$1" 176 181 } 177 182 ··· 213 218 if [[ $_os == "linux-musl" || $_os == "solaris" ]]; then 214 219 echo "" 215 220 else 216 - date -u +$format 221 + date -u +"$format" 217 222 fi 218 223 else 219 224 if [[ $_os == "linux-musl" || $_os == "solaris" ]]; then ··· 233 238 if [[ -z "$parsed" ]]; then 234 239 if [[ -n "$date" ]]; then 235 240 parsed_date="$(atfile.util.get_date "$date" 2> /dev/null)" 241 + # shellcheck disable=SC2181 236 242 [[ $? == 0 ]] && parsed="$parsed_date" 237 243 fi 238 244 fi ··· 262 268 didplc_doc="$(atfile.util.get_didplc_doc.request_doc "$didplc_endpoint" "$actor")" 263 269 fi 264 270 265 - echo "$(echo $didplc_doc | jq ". += {\"directory\": \"$didplc_endpoint\"}")" 271 + echo "$(echo "$didplc_doc" | jq ". += {\"directory\": \"$didplc_endpoint\"}")" 266 272 } 267 273 268 274 function atfile.util.get_didweb_doc_url() { ··· 380 386 output_last_line_length="${#output_last_line}" 381 387 382 388 echo -e "$output" 383 - echo -e "$(atfile.util.repeat_char "-" $output_last_line_length)" 389 + echo -e "$(atfile.util.repeat_char "-" "$output_last_line_length")" 384 390 } 385 391 386 392 function atfile.util.get_file_size_pretty() { ··· 411 417 *".host.bsky.network") max_filesize=1073741824 ;; 412 418 esac 413 419 414 - if [[ -z $max_filesize ]] || [[ $max_filesize == 0 ]] || (( $size < $max_filesize )); then 420 + if [[ -z $max_filesize ]] || [[ $max_filesize == 0 ]] || (( size < max_filesize )); then 415 421 echo 0 416 422 else 417 423 echo $(( size - max_filesize )) ··· 420 426 421 427 function atfile.util.get_file_type_emoji() { 422 428 mime_type="$1" 423 - short_type="$(echo $mime_type | cut -d "/" -f 1)" 424 - desc_type="$(echo $mime_type | cut -d "/" -f 2)" 429 + short_type="$(echo "$mime_type" | cut -d "/" -f 1)" 430 + desc_type="$(echo "$mime_type" | cut -d "/" -f 2)" 425 431 426 432 case $short_type in 427 433 "application") ··· 496 502 input="$1" 497 503 index=$(( $2 + 1 )) 498 504 499 - echo "$(echo -e "$input" | sed -n "$(( $index ))"p)" 505 + echo "$(echo -e "$input" | sed -n "$(( index ))"p)" 500 506 } 501 507 502 508 function atfile.util.get_mediainfo_field() { ··· 535 541 samplings=$(atfile.util.get_mediainfo_field "$file" "Audio" "SamplingRate" 0) 536 542 titles="$(atfile.util.get_mediainfo_field "$file" "Audio" "Title" "")" 537 543 538 - lines="$(echo "$bitrates" | wc -l)" 544 + lines="$(echo "$bitRates" | wc -l)" 539 545 output="" 540 546 541 - for ((i = 0 ; i < $lines ; i++ )); do 547 + for (( i = 0 ; i < lines ; i++ )); do 542 548 lossy=true 543 549 544 - [[ \"$(atfile.util.get_line "$compressions" $i)\" == "Lossless" ]] && lossy=false 550 + [[ $(atfile.util.get_line "$compressions" $i) == "Lossless" ]] && lossy=false 545 551 546 552 output+="{ 547 553 \"bitRate\": $(atfile.util.get_line "$bitRates" $i), ··· 576 582 frameRate_modes="$(atfile.util.get_mediainfo_field "$file" "Video" "FrameRate_Mode" "")" 577 583 titles="$(atfile.util.get_mediainfo_field "$file" "Video" "Title" "")" 578 584 579 - lines="$(echo "$bitrates" | wc -l)" 585 + lines="$(echo "$bitRates" | wc -l)" 580 586 output="" 581 587 582 588 for ((i = 0 ; i < lines ; i++ )); do ··· 692 698 path="$1" 693 699 694 700 if [[ $_os == "solaris" ]]; then 695 - # INVESTIGATE: Use this for every OS? What does this even do? 701 + # SEE: https://stackoverflow.com/a/11554895 702 + # INVESTIGATE: Use this for every OS? 703 + # shellcheck disable=SC2015 696 704 [ -d "$path" ] && ( 705 + # shellcheck disable=SC1007 697 706 cd_path= \cd "$1" 698 707 /bin/pwd 699 708 ) || ( 709 + # shellcheck disable=SC1007 700 710 cd_path= \cd "$(dirname "$1")" && 701 711 printf "%s/%s\n" "$(/bin/pwd)" "$(basename "$1")" 702 712 ) ··· 761 771 found_line="$(cat "$file" | grep "\b${variable}=")" 762 772 763 773 if [[ -n "$found_line" ]] && [[ ! "$found_line" == \#* ]]; then 764 - output="$(echo $found_line | sed "s|${variable}=||g")" 774 + output="$(echo "$found_line" | sed "s|${variable}=||g")" 765 775 output="${output%\"}" 766 776 output="${output#\"}" 767 777 ··· 871 881 case $segment in 872 882 "host") echo "$uri" | cut -d "/" -f 3 ;; 873 883 "protocol") echo "$uri" | cut -d ":" -f 1 ;; 874 - *) echo "$uri" | cut -d "/" -"f $segme"nt ;; 884 + *) echo "$uri" | cut -d "/" -f "$segment" ;; 875 885 esac 876 886 } 877 887 ··· 904 914 fi 905 915 fi 906 916 907 - echo $at_uri 917 + echo "$at_uri" 908 918 } 909 919 910 920 # HACK: This essentially breaks the entire session (it overrides $_username and ··· 956 966 v_major="$(printf "%04d\n" "$(echo "$version" | cut -d "." -f 1)")" 957 967 v_minor="$(printf "%04d\n" "$(echo "$version" | cut -d "." -f 2)")" 958 968 v_rev="$(printf "%04d\n" "$(echo "$version" | cut -d "." -f 3)")" 959 - echo "$(echo ${v_major}${v_minor}${v_rev} | sed 's/^0*//')" 969 + echo "$(echo "${v_major}${v_minor}${v_rev}" | sed 's/^0*//')" 960 970 } 961 971 962 972 function atfile.util.print_blob_url_output() { ··· 1047 1057 didplc_dir="$(echo "$did_doc" | jq -r ".directory")" 1048 1058 pds="$(echo "$did_doc" | jq -r '.service[] | select(.id == "#atproto_pds") | .serviceEndpoint')" 1049 1059 1050 - while IFS=$"\n" read -r a; do 1060 + while IFS=$'\n' read -r a; do 1051 1061 aliases+="$a;" 1052 1062 1053 1063 if [[ -z $handle && "$a" == "at://"* && "$a" != "at://did:"* ]]; then ··· 1074 1084 atfile.util.get_cache "$file" 1075 1085 1076 1086 echo -e "$content" > "$file_path" 1087 + # shellcheck disable=SC2320 1088 + # shellcheck disable=SC2181 1077 1089 [[ $? != 0 ]] && atfile.die "Unable to write to cache file ($file)" 1078 1090 }
+2 -2
src/shared/xrpc.sh
··· 34 34 function atfile.xrpc.pds.jwt() { 35 35 atfile.http.post \ 36 36 "$_server/xrpc/com.atproto.server.createSession" \ 37 - '{"identifier": "'$_username'", "password": "'$_password'"}' | jq -r ".accessJwt" 37 + '{"identifier": "'"$_username"'", "password": "'"$_password"'"}' | jq -r ".accessJwt" 38 38 } 39 39 40 40 function atfile.xrpc.pds.post() { ··· 44 44 45 45 [[ -z $type ]] && type="application/json" 46 46 47 - curl -s -X POST $_server/xrpc/$lexi \ 47 + curl -s -X POST "$_server/xrpc/$lexi" \ 48 48 -H "Authorization: Bearer $(atfile.xrpc.pds.jwt)" \ 49 49 -H "Content-Type: $type" \ 50 50 -H "User-Agent: $(atfile.util.get_uas)" \