šŸ“¦āž”šŸ¦‹ Store and retrieve files on the Atmosphere
35
fork

Configure Feed

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

tangled/dev āž” dev

Ducky 6ed130ef 86aa1fce

+66 -86
+23 -33
src/commands/install.sh
··· 5 5 override_version="$2" 6 6 7 7 uid="$(id -u)" 8 - conf_file="atfile.env" 8 + conf_dir="${_path_envvar%/*}" 9 9 install_file="atfile" 10 - unset conf_dir 11 10 unset install_dir 12 11 13 12 atfile.util.check_prog "curl" 14 13 atfile.util.check_prog "jq" 15 14 15 + # shellcheck disable=SC2154 16 16 if [[ $_os_supported == 0 ]]; then 17 17 atfile.die "Unsupported OS (${_os//unknown-/})" 18 18 fi 19 19 20 - if [[ $_os == "haiku" ]]; then 21 - install_dir="/boot/system/non-packaged/bin" 22 - conf_dir="$HOME/config/settings" 23 - else 24 - if [[ $uid == 0 ]]; then 25 - install_dir="/usr/local/bin" 26 - 27 - if [[ -z $SUDO_DIR ]]; then 28 - conf_dir="/root/.config" 29 - else 30 - if [[ $_os == "macos" ]]; then 31 - conf_dir="$(eval echo ~"$SUDO_USER")/Library/Application Support" 32 - else 33 - conf_dir="$(eval echo ~"$SUDO_USER")/.config" 34 - fi 35 - fi 36 - else 37 - install_dir="$(eval echo ~"$USER")/.local/bin" 38 - conf_dir="$(eval echo ~"$USER")/.config" 39 - 40 - if [[ $_os == "macos" ]]; then 41 - conf_dir="$(eval echo ~"$USER")/Library/Application Support" 20 + case $_os in 21 + "haiku") 22 + install_dir="/boot/system/non-packaged/bin" 23 + ;; 24 + *) 25 + if [[ $uid == 0 ]]; then 26 + install_dir="/usr/local/bin" 42 27 else 43 - conf_dir="$(eval echo ~"$USER")/.config" 28 + install_dir="$_path_home/.local/bin" 44 29 fi 45 - fi 46 - 47 - # INVESTIGATE: What happens during `sudo`? 48 - if [[ -n "$XDG_CONFIG_HOME" ]]; then 49 - conf_dir="$XDG_CONFIG_HOME" 50 - fi 51 - fi 30 + ;; 31 + esac 52 32 53 33 [[ -n "$override_path" ]] && install_dir="$override_path" 34 + mkdir -p "$conf_dir" 35 + touch "$conf_dir/$_file_envvar" 54 36 55 - atfile.say.debug "Installing...\n↳ OS: $_os\n↳ Install: $install_dir/$install_file\n↳ Config: $conf_dir/$conf_file" 37 + atfile.say.debug "Installing...\n↳ OS: $_os\n↳ Install: $install_dir/$install_file\n↳ Config: $conf_dir/$_file_envvar" 56 38 57 39 if [[ -f "$install_dir/$install_file" ]]; then 58 40 atfile.die "Already installed ($install_dir/$install_file)" 59 41 fi 42 + 43 + atfile.say "šŸ˜Ž Installed ATFile" 44 + atfile.say " ↳ Path: $install_dir/$install_file" 45 + atfile.say " ↳ Config: $conf_dir/$_file_envvar" 46 + atfile.say " ---" 47 + atfile.say " Before running, set your credentials in the config file!" 48 + atfile.say " Run '$install_file help' to get started" 49 + # ------------------------------------------------------------------------------ 60 50 }
+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") 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")
+42 -46
src/entry.sh
··· 6 6 7 7 _start="$(atfile.util.get_date "" "%s")" # 1 8 8 _envvar_prefix="ATFILE" # 2 9 - _debug="$(atfile.util.get_envvar "${_envvar_prefix}_DEBUG" "0")" # 3 9 + _debug="$(atfile.util.get_envvar "${_envvar_prefix}_DEBUG" "$([[ $ATFILE_DEVEL == 1 ]] && echo 1 || echo 0)")" # 3 10 10 _command="$1" 11 11 _command_args=("${@:2}") 12 12 _os="$(atfile.util.get_os)" ··· 23 23 ## "Hello, world!" 24 24 25 25 atfile.say.debug "Reticulating splines..." 26 + 27 + ## Paths 28 + 29 + _path_home="$HOME" 30 + 31 + if [[ -n "$SUDO_USER" ]]; then 32 + _path_home="$(eval echo "~$SUDO_USER")" 33 + fi 34 + 35 + _file_envvar="atfile.env" 36 + _path_blobs_tmp="/tmp" 37 + _path_cache="$_path_home/.cache" 38 + _path_envvar="$_path_home/.config" 39 + 40 + # BUG: ATFILE_FORCE_OS cannot overwrite this 41 + case $_os in 42 + "haiku") 43 + _path_blobs_tmp="/boot/system/cache/tmp" 44 + _path_cache="$_path_home/config/cache" 45 + _path_envvar="$_path_home/config/settings" 46 + ;; 47 + "linux-termux") 48 + _path_blobs_tmp="/data/data/com.termux/files/tmp" 49 + ;; 50 + "macos") 51 + _path_envvar="$_path_home/Library/Application Support" 52 + _path_blobs_tmp="/private/tmp" 53 + ;; 54 + esac 55 + 56 + if [[ -n "$XDG_CONFIG_HOME" ]]; then 57 + _path_envvar="$XDG_CONFIG_HOME" 58 + fi 59 + 60 + _path_blobs_tmp="$_path_blobs_tmp/at-blobs" 61 + _path_cache="$_path_cache/atfile" 62 + _path_envvar="$(atfile.util.get_envvar "${_envvar_prefix}_PATH_CONF" "$_path_envvar/$_file_envvar")" 26 63 27 64 ## OS detection 28 65 ··· 86 123 _prog_dir="$(dirname "$(atfile.util.get_realpath "$0")")" 87 124 _prog_path="$(atfile.util.get_realpath "$0")" 88 125 89 - ## Paths 90 - 91 - _path_home="$HOME" 92 - 93 - if [[ -n "$SUDO_USER" ]]; then 94 - _path_home="$(eval echo "~$SUDO_USER")" 95 - fi 96 - 97 - _file_envvar="atfile.env" 98 - _path_blobs_tmp="/tmp" 99 - _path_cache="$_path_home/.cache" 100 - _path_envvar="$_path_home/.config" 101 - 102 - # BUG: ATFILE_FORCE_OS cannot overwrite this 103 - case $_os in 104 - "haiku") 105 - _path_blobs_tmp="/boot/system/cache/tmp" 106 - _path_cache="$_path_home/config/cache" 107 - _path_envvar="$_path_home/config/settings" 108 - ;; 109 - "linux-termux") 110 - _path_blobs_tmp="/data/data/com.termux/files/tmp" 111 - ;; 112 - "macos") 113 - _path_envvar="$_path_home/Library/Application Support" 114 - _path_blobs_tmp="/private/tmp" 115 - ;; 116 - esac 117 - 118 - if [[ -n "$XDG_CONFIG_HOME" ]]; then 119 - _path_envvar="$XDG_CONFIG_HOME" 120 - fi 121 - 122 - _path_blobs_tmp="$_path_blobs_tmp/at-blobs" 123 - _path_cache="$_path_cache/atfile" 124 - _path_envvar="$(atfile.util.get_envvar "${_envvar_prefix}_PATH_CONF" "$_path_envvar/$_file_envvar")" 125 - 126 126 ## Envvars 127 127 128 128 ### Fallbacks ··· 134 134 135 135 ### Defaults 136 136 137 - _debug_default=$([[ $ATFILE_DEVEL == 1 ]] && echo 1 || echo 0) 138 137 _devel_publish_default=0 139 138 _disable_pbc_fallback_default=0 140 139 _disable_update_checking_default=0 ··· 163 162 164 163 ### Set 165 164 166 - _debug="$(atfile.util.get_envvar "${_envvar_prefix}_DEBUG" "$_debug_default")" 167 165 _devel_publish="$(atfile.util.get_envvar "${_envvar_prefix}_DEVEL_PUBLISH" $_devel_publish_default)" 168 166 _disable_pbc_fallback="$(atfile.util.get_envvar "${_envvar_prefix}_DISABLE_PBC_FALLBACK" $_disable_pbc_fallback_default)" 169 167 _disable_update_checking="$(atfile.util.get_envvar "${_envvar_prefix}_DISABLE_UPDATE_CHECKING" $_disable_update_checking_default)" ··· 250 248 251 249 ## OS detection 252 250 253 - atfile.say.debug "Checking OS is supported..." 254 - 255 251 if [[ $_os_supported == 0 ]]; then 256 252 if [[ $_skip_unsupported_os_warn == 0 ]]; then 257 253 atfile.die "Unsupported OS (${_os//unknown-/})\n↳ Set ${_envvar_prefix}_SKIP_UNSUPPORTED_OS_WARN=1 to ignore" ··· 275 271 [[ $_os != "haiku" && $_os != "solaris" ]] && atfile.util.check_prog "file" "https://www.darwinsys.com/file" 276 272 atfile.util.check_prog "jq" "$_prog_hint_jq" 277 273 [[ $_skip_ni_md5sum == 0 ]] && atfile.util.check_prog "md5sum" "" "${_envvar_prefix}_SKIP_NI_MD5SUM" 274 + #[[ $_os == "haiku" ]] && atfile.util.check_prog "perl" 278 275 279 276 # Main 280 277 ··· 311 308 312 309 ## Default 313 310 314 - if [[ $_is_sourced == 0 && -z $_command ]]; then 315 - atfile.util.override_command "help" 316 - fi 311 + [[ $_is_sourced == 0 && -z $_command ]] && _command="help" 317 312 318 313 if [[ "$_command" == "atfile:"* || "$_command" == "at:"* || "$_command" == "https:"* ]]; then 319 - atfile.util.override_command "handle" "$_command" 314 + _command="handle" 315 + _command_args=("$1") 320 316 atfile.say.debug "Handling '${_command_args[*]}'..." 321 317 fi 322 318
-6
src/shared/util.sh
··· 983 983 atfile.say.debug "Overridden identity\n↳ DID: $_username\n↳ PDS: $_server\n↳ Blob URL: $_fmt_blob_url" 984 984 } 985 985 986 - function atfile.util.override_command() { 987 - _command="$1" 988 - _command_args=("${@:2}") 989 - atfile.say.debug "Overridden command\n↳ Command: $_command\n↳ Arguments: ${_command_args[*]}" 990 - } 991 - 992 986 # NOTE: This is to help during sourcing if atfile.uitl.override_actor() has 993 987 # been called 994 988 function atfile.util.override_actor_reset() {