Snippets
Revised by
Kirk Duncan
fed0d39
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 | #! /usr/bin/env sh # ------------------------------------------------------------------------------------------------------------ # # NOTE: 2011 laptop has called it a day -- with all my everything. # Not sure what the next move is, will take some time. # Cannot test or run any of this. # So, your turn. Bye. # ------------------------------------------------------------------------------------------------------------ # # Table of Contents # 1) Introduction # 2) Debug # 3) Security # 4) Standard out # 5) Short circuit # 6) Domain # 7) Call stack # 8) Helper functions # 9) Entry point # 10) Appendix # ------------------------------------------------------------------------------------------------------------ # # INTRODUCTION ---------------------------------------------------------------------------------------------- # # ------------------------------------------------------------------------------------------------------------ # # Version control repositories that allow users to include binary files: # gradle/wrapper/gradle-wrapper.jar # # Gradle 2021, Verifying the integrity of the Gradle Wrapper JAR, The Gradle Wrapper, viewed 04 February 2021, # <https://docs.gradle.org/current/userguide/gradle_wrapper.html#wrapper_checksum_verification> # # Enjoy Gradle? Meet Hugh, he programs the sht out of it! Thanks Hugh. # # Greene, H 2021, The Holy Gradle, holygradle-plugins, viewed 25 March 2021, # https://bitbucket.org/HughG/holygradle-plugins/src/master/ # # Life's better with music. # # Jackson, E 2009, Bulletproof, La Roux, Spotify, Youtube, # https://open.spotify.com/track/3kMrazSvILsgcwtidZd1Qd?si=afef67527d5f4e4f # https://youtu.be/Kk8eJh4i8Lo # ------------------------------------------------------------------------------------------------------------ # # DEBUG ------------------------------------------------------------------------------------------------------ # # ------------------------------------------------------------------------------------------------------------ # # Prints trace report to file and the current options available for this shell to the terminal, # invoke via; -debug <command>, --debug <command>. Refer to Appendix 1 _print_set_debug() { exec 2>auditgradle.debug; set -xo; } # ------------------------------------------------------------------------------------------------------------ # # SECURITY --------------------------------------------------------------------------------------------------- # # ------------------------------------------------------------------------------------------------------------ # # FIXME: The last task. # TODO: Appendix 2 # REMOVE: cd() { command cd "$@" >/dev/null; pwd; } # <- parent function is not invoked # $ man command: Examples 2. Start off a 'secure shell script' [a juvenile delinquent]. IFS=' ' # FIXME: Set IFS to its default value <space><tab><newline>. Double check IFS for correctness # ------------------------------------------------------------------------------------------------------------ # # Unset all possible aliases. \unalias -a # ------------------------------------------------------------------------------------------------------------ # # Ensure command is not a user function. unset -f command # ------------------------------------------------------------------------------------------------------------ # # Put on a reliable PATH prefix. # before: /usr/bin/* # after: /bin/* PATH="$(command -p getconf PATH):$PATH" # # The Open Group 2018, command - execute a simple command, Base Specifications Issue 7, 2018 edt, # viewed 24 March 2021, https://pubs.opengroup.org/onlinepubs/9699919799/utilities/command.html # # ------------------------------------------------------------------------------------------------------------ # # STANDARD OUT ----------------------------------------------------------------------------------------------- # # ------------------------------------------------------------------------------------------------------------ # # Prints information to the users terminal. # Appendix 3 _print_info() { env printf "%s \n" "$*" 1>&2; } # ------------------------------------------------------------------------------------------------------------ # # Invoke via; -h, -help, --help, -\?. _print_help() { cat 0<<_EOF_ Usage: ${0##*/} [-h|-help|--help] | [[-g|-get|--get] <version> <checksum>] | [[-c|-check|--check] <version>] | [[-u|-upgrade|--upgrade] <version> <checksum>] -g, -get, --get VERSION="\$2" CHECKSUM="\$3" $ gradle wrapper \\ --gradle-version "\$VERSION" \\ --distribution-type all \\ --gradle-distribution-sha256-sum "\$CHECKSUM" # -------------------------------------------------------------------- # Gradle 2021, Gradle distribution and wrapper JAR checksum reference, viewed 04 February 2021, <https://gradle.org/release-checksums/> # -------------------------------------------------------------------- # Integrated Development Environment (IDE) pulls: Complete (-all|-bin) ZIP Checksum gradle/wrapper/gradle.wrapper.properties # -------------------------------------------------------------------- # Command Line Interface (CLI) pulls: Wrapper JAR Checksum $ ./gradlew tasks # -------------------------------------------------------------------- # -c, -check, --check VERSION="\$2" $ cd \$PWD/gradle/wrapper $ wget --tries=1 \\ --no-cookies \\ --max-redirect=0 \\ --secure-protocol=TLSv1_2 \\ --append-output=auditgradle.log \\ --output-document=gradle-wrapper.jar.sha256 \\ --header="Accept: application/gzip, application/octet-stream" \\ https://downloads.gradle-dn.com/distributions/gradle-"\$VERSION"-wrapper.jar.sha256 $ echo " gradle-wrapper.jar" >> gradle-wrapper.jar.sha256 $ sha256sum --check gradle-wrapper.jar.sha256 # -------------------------------------------------------------------- # -u, -upgrade, --upgrade VERSION="\$2" CHECKSUM="\$3" $ ./gradlew wrapper \\ --gradle-version "\$VERSION" \\ --distribution-type all \\ --gradle-distribution-sha256-sum "\$CHECKSUM" Run the following commands: $ jcmd -l > org.gradle.launcher.daemon.bootstrap.GradleDaemon \$VERSION $ ./gradlew --stop > Stopping Daemon(s) > 1 Daemon stopped _EOF_ } # -------------------------------------------------------------------------------------------------- # # SHORT CIRCUIT ------------------------------------------------------------------------------------ # # -------------------------------------------------------------------------------------------------- # # Zero positional arguments upon initialisation prints the help message to the users terminal. if [ $# -eq 0 ]; then _print_help 2>/dev/null; exit 1; fi # -------------------------------------------------------------------------------------------------- # # DOMAIN ------------------------------------------------------------------------------------------- # # -------------------------------------------------------------------------------------------------- # # Ensure the users system has the utilities available in-order to process the calls made by # this script. Refer to Appendix 4. # (B -> D -> E) -> stdout # TEST: builtin command -V "$1"; throwing errors in a wsl terminal, try again in native linux os. _check_dependency() { if ! (command -V "$1" >/dev/null 2>&1); then _print_info "ERROR: missing dependency can't find $1" exit 1 fi } # -------------------------------------------------------------------------------------------------- # # From the present working directory check the user's path includes gradle/wrapper/ and neither # directory is a symbolic representation. Then call the Gradle host with wget and output a https # auditGradle.log and the gradle-wrapper.jar.sha256 file. Refer to Appendix 5. _check_gradle_wrapper() { version="$1" root=$(env pwd -P) location="$root/gradle/wrapper" # ------------------------------------------------------------------------------------------------ # if [ -d "$location" ]; then if [ -h "$root"/gradle ] || [ -h "$root"/gradle/wrapper ]; then _print_info "Either directory is a symbolic link: \$PWD/gradle/wrapper"; exit 1; else cd -P "$location" 2>/dev/null || { _print_info "cd action failed"; exit 1; } fi else _print_info "No such directory: \$PWD/gradle/wrapper"; exit 1; fi # ------------------------------------------------------------------------------------------------ # _print_info "downloading $version of gradle-wrapper.jar.sha256..." # ------------------------------------------------------------------------------------------------ # wget --tries=1 \ --no-cookies \ --max-redirect=0 \ --secure-protocol=TLSv1_2 \ --output-document=gradle-wrapper.jar.sha256 \ --append-output="$root/auditgradle.log" \ --header="Accept: application/gzip, application/octet-stream" \ https://downloads.gradle-dn.com/distributions/gradle-"$version"-wrapper.jar.sha256 # ------------------------------------------------------------------------------------------------ # _print_info "wget's verify-gradle-wrapper.log in $root..." } # -------------------------------------------------------------------------------------------------- # # From the present working directory use the system's Gradle distribution to pull a gradle # wrapper version with the associated checksum. Distribution type all enables both IDE # code-completion and Gradle documentation. _get_gradle_wrapper() { version="$1" checksum="$2" # ------------------------------------------------------------------------------------------------ # _print_info "Wrapper JAR Checksum: $checksum" _print_info "Downloading $version of gradle-wrapper.jar..." # ------------------------------------------------------------------------------------------------ # gradle wrapper \ --gradle-version "$version" \ --distribution-type all \ --gradle-distribution-sha256-sum "$checksum" } # -------------------------------------------------------------------------------------------------- # # In the present working directory find the projects gradlew executable. Then update to the # gradle wrapper version with the associated checksum. Distribution type all enables both IDE # code-completion and Gradle documentation. Refer to Appendix 6. _upgrade_gradle_wrapper() { version="$1" checksum="$2" # ------------------------------------------------------------------------------------------------ # gw=$(find -P . -maxdepth 1 -mindepth 1 -mount -executable -name 'gradlew' -readable -type f) if [ -z "$gw" ]; then _print_info "ERROR: gradlew not found in current working directory"; exit 1; fi # ------------------------------------------------------------------------------------------------ # _print_info "Wrapper JAR Checksum: $checksum" _print_info "Downloading $version of gradle-wrapper.jar..." # ------------------------------------------------------------------------------------------------ # $gw wrapper \ --gradle-version "$version" \ --distribution-type all \ --gradle-distribution-sha256-sum "$checksum" } # -------------------------------------------------------------------------------------------------- # # From the projects gradle/wrapper directory check the local gradle-wrapper.jar checksum. # Refer to Appendix 7. _shasum_gradle_wrapper() { _print_info "checking sha256 of gradle-wrapper.jar..." # ------------------------------------------------------------------------------------------------ # echo " gradle-wrapper.jar" 1>> gradle-wrapper.jar.sha256 # ------------------------------------------------------------------------------------------------ # sha256sum --check gradle-wrapper.jar.sha256 # ------------------------------------------------------------------------------------------------ # SHA256=$(cat gradle-wrapper.jar.sha256) SHA256SUM=$(sha256sum gradle-wrapper.jar) # ------------------------------------------------------------------------------------------------ # _print_info "1) sha256: $SHA256" _print_info "2) sha256sum: $SHA256SUM" # ------------------------------------------------------------------------------------------------ # rm --interactive=once --verbose gradle-wrapper.jar.sha256 } # -------------------------------------------------------------------------------------------------- # # CALL STACK --------------------------------------------------------------------------------------- # # -------------------------------------------------------------------------------------------------- # # Check the parent system has the required utilities installed; wget, sha256sum, # and make a call to two script functions. _run_check() { _print_info "Running: check gradle wrapper" # ------------------------------------------------------------------------------------------------ # _check_dependency wget _check_dependency sha256sum # ------------------------------------------------------------------------------------------------ # _check_gradle_wrapper "$1" _shasum_gradle_wrapper } # -------------------------------------------------------------------------------------------------- # # Check the parent system has the required utility installed; gradle, and call a script function. _run_get() { _print_info "Running: get gradle wrapper" # ------------------------------------------------------------------------------------------------ # _check_dependency gradle # ------------------------------------------------------------------------------------------------ # _get_gradle_wrapper "$1" "$2" } # -------------------------------------------------------------------------------------------------- # # Run the scripts function to upgrade the gradle-wrapper.jar. _run_upgrade() { _print_info "Running: upgrade gradle wrapper" # ------------------------------------------------------------------------------------------------ # _upgrade_gradle_wrapper "$1" "$2" } # -------------------------------------------------------------------------------------------------- # # HELPER FUNCTIONS --------------------------------------------------------------------------------- # # -------------------------------------------------------------------------------------------------- # # Checks regular expression for natural numbers: # <digit>.<digit> or <digit>.<digit>.<digit> # <digit><digit>.<digit><digit> or <digit><digit>.<digit><digit>.<digit><digit> # # Pattern conforms to the Gradle continuum policy. Refer to Appendix 8. _confirm_version() { VERSION=$( expr "$1" : '\(^\([0-9]\{1,2\}\.[0-9]\{1,2\}\.[0-9]\{1,2\}\)$\|^\([0-9]\{1,2\}\.[0-9]\{1,2\}\)$\)' 2>/dev/null ) } # -------------------------------------------------------------------------------------------------- # # Checksum must conform to a length of 64 containing only Hindu-Arabic Numerals and # the English language lowercase letters. Refer to Appendix 8. _confirm_checksum() { CHECKSUM=$( expr "$1" : '^\([0-9a-z]\{64\}\)$' 2>/dev/null ) } # -------------------------------------------------------------------------------------------------- # # The user's input checksum conforms to a length of 64. Refer to Appendix 8. _confirm_length() { return $( expr length "$1" = 64 >/dev/null 2>&1 ); } # -------------------------------------------------------------------------------------------------- # VERSION_MSG="Version format is numerical (i.e., 5.2 also 6.8.3): <digit>.<digit>.?<digit>?" # These are global variables, duplication at the function level is intentional for flexibility. VERSION= CHECKSUM= # -------------------------------------------------------------------------------------------------- # # ENTRY POINT -------------------------------------------------------------------------------------- # # -------------------------------------------------------------------------------------------------- # if [ "$1" = "-debug" ] || [ "$1" = "--debug" ]; then shift; _print_set_debug; fi # -------------------------------------------------------------------------------------------------- # case "$1" in ( -c | -check | --check ) if [ "$2" ]; then maybe="$2" _confirm_version "$maybe" if [ "$VERSION" = "$maybe" ]; then _run_check "$VERSION" else _print_info "$VERSION_MSG" fi else _print_info "Option requires an argument: $1 <version>" fi ;; ( -g | -get | --get ) if [ "$2" ] && [ "$3" ]; then maybe="$2" _confirm_version "$maybe" if [ "$VERSION" = "$maybe" ]; then kinda="$3" if ( _confirm_length "$kinda" ); then _confirm_checksum "$kinda" if [ "$CHECKSUM" = "$kinda" ]; then _run_get "$VERSION" "$CHECKSUM" else _print_info "Invalid gradle checksum: $3" fi else _print_info "Invalid checksum length: $3" fi else _print_info "$VERSION_MSG" fi else _print_info "Option requires two arguments: $1 <version> <checksum>" fi ;; ( -h | -help | --help | -\? ) _print_help 1>&2 ;; ( -u | -upgrade | --upgrade ) if [ "$2" ] && [ "$3" ]; then maybe="$2" _confirm_version "$maybe" if [ "$VERSION" = "$maybe" ]; then kinda="$3" if ( _confirm_length "$kinda" ); then _confirm_checksum "$kinda" if [ "$CHECKSUM" = "$kinda" ]; then _run_upgrade "$VERSION" "$CHECKSUM" else _print_info "Invalid gradle checksum: $3" fi else _print_info "Invalid checksum length: $3" fi else _print_info "$VERSION_MSG" fi else _print_info "Option requires two arguments: $1 <version> <checksum>" fi ;; ( * ) _print_info "Option $1 invalid argument." ;; esac exit $? # -------------------------------------------------------------------------------------------------- # # APPENDICES --------------------------------------------------------------------------------------- # # -------------------------------------------------------------------------------------------------- # # Appendix 1 - _print_set_debug # # set -o # Write the current settings of the options to standard output in an unspecified format. # # set -x # The shell shall write to standard error a trace for each command after it expands the command and before it executes it. # # example: # $ ./auditgradle.sh -debug -check 6.8.3 # $ less auditgradle.debug # # The Open Group 2018, set - set or unset options and positional parameters, Base Specifications Issue 7, 2018 edt, # viewed 24 March 2021, https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_25 # # -------------------------------------------------------------------------------------------------- # # Appendix 2 - IFS='<space><tab><newline>' # # Text editors are subject to user configurations (kakoune/editorconfig), also # repositories or transit may introduce anomalies. Double check the IFS # environment variable prior to running. # # -------------------------------------------------------------------------------------------------- # # Appendix 3 - _print_info # # printf: Due to shell aliases and built-in printf functions, using an unadorned printf # interactively or in a script may get you different functionality [...]. Invoke # it via env (i.e., env printf …) to avoid interference from the shell. # # GNU 2020, 15.2 printf: Format and print data, GNU Coreutils, viewed 24 March 2021, # https://www.gnu.org/software/coreutils/manual/html_node/printf-invocation.html # # -------------------------------------------------------------------------------------------------- # # Appendix 4 - _check_dependency # # Command Search and Execution # -------------------------------------------------------------- # A) 2.14. Special Built-In Utilities # break exec set # colon exit shift # continue export times # dot readonly trap # eval return unset # -------------------------------------------------------------- # B) # alloc comparguments comptry history pushd # autoload compcall compvalues hist readarray # bind compctl declare let repeat # bindkey compdescribe dirs local savehistory # builtin compfiles disable login source # bye compgen disown logout shopt # caller compgroups dosh map stop # cap complete echotc mapfile suspend # chdir compquote echoti popd typeset # clone comptags help print whence # --------------------------------------------------------------- # C) 2.9.5 Function Definition Command # --------------------------------------------------------------- # D) # alias false hash pwd unalias # bg fc jobs read wait # cd fg kill true # command getopts newgrp umask # --------------------------------------------------------------- # E) # path # --------------------------------------------------------------- # IEEE and The Open Group 2018, Command Search and Execution, viewed 28 March 2021, # https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_01_01 # # IEEE and The Open Group 2018, command - execute a simple command, viewed 28 March 2021, # https://pubs.opengroup.org/onlinepubs/9699919799/utilities/command.html # # -------------------------------------------------------------------------------------------------- # # Appendix 5 - _check_gradle_wrapper # # env --chdir=GUARANTEED_PATH, path is unsubstantiated: `pwd`/gradle/wrapper # # The default behaviour is --physical; pwd, realpath, cd. # realpath --no-symlinks does not --canonicalize-existing path for symlinks. # cd -P into a physical directory not it's symbolic representation. # # If either directories; gradle, gradle/wrapper is a symbolic then a base directory # is not honoured given the below utility function: # realpath --canonicalize-existing --physical --relative-base="$root" gradle/wrapper # # Redirects +1 # Referer: https://services.gradle.org/distributions/ # Host: downloads.gradle-dn.com # As at 30 March 2021, wget --secure-protocol=TLSv1_3 is unsupported at host # # wget --input-file=If there are URLs both on the command line and in an input file, those on the # command lines will be the first ones to be retrieved. # # pwd: Due to shell aliases and built-in pwd functions, using an unadorned pwd # interactively or in a script may get you different functionality [...]. # Invoke it via env (i.e., env pwd …) to avoid interference from the shell. # # $ env --ignore-environment --debug pwd -P # > cleaning environ # > executing: pwd # > arg[0]= ‘pwd’ # > arg[1]= ‘-P’ # # GNU 2021, 2.4 Logging and Input File Options, GNU Wget 1.21.1-dirty Manual, viewed 23 March 2021, # https://www.gnu.org/software/wget/manual/html_node/Logging-and-Input-File-Options.html # # GNU 2020, 19.1 pwd: Print working directory, Coreutils - GNU core utilities, viewed 23 March 2021, # https://www.gnu.org/software/coreutils/manual/html_node/pwd-invocation.html # # GNU 2020, 23.2 env: Run a command in a modified environment, Coreutils - GNU core utilities, viewed 23 March 2021, # https://www.gnu.org/software/coreutils/manual/html_node/env-invocation.html # # -------------------------------------------------------------------------------------------------- # # Appendix 6 - _upgrade_gradle_wrapper # # find (Options Globals Tests) # where # Options = -P # Globals = -maxdepth 1 -mindepth 1 -mount # Tests = -executable -name 'gradlew' -readable -type f # # GNU 2021, 8.1 Invoking find, GNU Findutils 4.8.0, viewed 29 March 2021, # https://www.gnu.org/software/findutils/manual/html_node/find_html/Invoking-find.html # # -------------------------------------------------------------------------------------------------- # # Appendix 7 - _shasum_gradle_wrapper # # rm --interactive=once prompts the user for confirmation if three or more files require deletion # # GNU 2020, 11.5 rm: Remove files or directories, GNU Coreutils Manual, viewed 29 March 2021, # https://www.gnu.org/software/coreutils/manual/html_node/rm-invocation.html # # -------------------------------------------------------------------------------------------------- # # Appendix 8 - _confirm_version, _confirm_checksum, _confirm_length # # version has; three groups, separated by '.' , start [0-9], middle [0-9], end [0-9] # version regex: (expr '6.8.3' : '^\([0-9]\{1,2\}\.[0-9]\{1,2\}\.[0-9]\{1,2\}\)$') returns match or null # # checksum has; a fixed length, no separation characters, contains [0-9a-z] # checksum regex: (expr '7faa7198769f872826c8ef4f1450f839ec27f0b4d5d1e51bade63667cbccd205' : '^\([0-9a-z]\{64\}\)$') return match or null # checksum length: (expr length '7faa7198769f872826c8ef4f1450f839ec27f0b4d5d1e51bade63667cbccd205' = 64) returns 1 or 0 # # length redirection: 2>/dev/null; returns 0 or 1 or null # length redirection: >/dev/null 2>&1; true or returns 1 or 2 # # GNU 2020, 16.4 expr: Evaluate expressions, GNU Coreutils Manual, viewed 31 March 2021, # https://www.gnu.org/software/coreutils/manual/html_node/expr-invocation.html # # gradle-completion 2017, Security risk (?): Backticks in descriptions are attempted to eval!, Issue #91, gradle/gradle-completion, # viewed 10 March 2021, https://github.com/gradle/gradle-completion/issues/91 # # -------------------------------------------------------------------------------------------------- # # Appendix 9 - stdin|stdout|stderr # --- +-----------------------+ # standard input ( 0 ) ---->| /dev/pts/N | # --- +-----------------------+ # # --- +-----------------------+ # standard output ( 1 ) ---->| /dev/pts/N | # --- +-----------------------+ # # --- +-----------------------+ # standard error ( 2 ) ---->| /dev/pts/N | # --- +-----------------------+ # # 0:1:2 # stdin:stdout:stderr # read:write:write # # 0:1:2 all point to /dev/pts/N we're redirecting this file descriptor location on # the command line. The numbers 0:1:2 are an abstraction over input:output:error. # (I paraphrase to ensure MY understanding, all research is referenced). # # [Re-directions] are set up by the shell 'before' the commands are executed, and the # commands inherit the file descriptors (note: order matters, left to right). # # Example: target>&source = t>&s = 1>&2 # # 0<<_EOF_; sdtin << read from stream # 2>/dev/null; stderr > sent to /dev/null (file descriptor) # 2>&1; stdout points to stderr (1 points to 2) # 1>&2; stderr points to stdout (2 points to 1) # # The Bash Hackers Wiki 2019, Syntax, Illustrated Redirection Tutorial, viewed 24 March 2021, # https://wiki.bash-hackers.org/howto/redirection_tutorial # # -------------------------------------------------------------------------------------------------- # # Appendix 10 - verify-gradle-wrapper.sh # # pathchk --portability verify-gradle-wrapper.sh # pathchk: limit 14 exceeded by length 24 of file name component ‘verify-gradle-wrapper.sh’ # # size counts from one: 0 < size.sh < 15 # pathchk --portability auditGradle.sh # pathchk --portability auditgradle.sh # # -------------------------------------------------------------------------------------------------- # |
You can clone a snippet to your computer for local editing. Learn more.