Overview
Comment: | update to mmmv_Fossil_operator_t1.bash |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
d6f691d449988776151161952b251e0c |
User & Date: | martin_vahi on 2016-09-05 00:34:48 |
Other Links: | manifest | tags |
Context
2016-10-29 18:19 | repository URL specific download script check-in: c0fe686fe4 user: martin_vahi tags: trunk | |
2016-09-05 00:34 | update to mmmv_Fossil_operator_t1.bash check-in: d6f691d449 user: martin_vahi tags: trunk | |
2016-08-20 07:49 | Silktorrent propaganda leaflet check-in: 56f9b20300 user: martin_vahi tags: trunk | |
Changes
Modified work_in_progress/mmmv_Fossil_operator_t1.bash from [31cc9fef70] to [ebb536fdad].
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 .. 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 .. 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 ... 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 ... 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 ... 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 ... 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 ... 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 ... 267 268 269 270 271 272 273 274 275 276 277 278 279 280 ... 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 ... 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 ... 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 ... 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 ... 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 ... 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 ... 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 ... 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 ... 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 ... 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 ... 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 ... 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 ... 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 ... 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 ... 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 ... 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 .... 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 .... 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 .... 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 .... 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 |
# Initial author: Martin.Vahi@softf1.com # This file is in the public domain. #========================================================================== S_FP_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" S_FP_ORIG="`pwd`" S_TIMESTAMP="`date +%Y`_`date +%m`_`date +%d`_T_`date +%H`h_`date +%M`min_`date +%S`s" fun_assert_exists_on_path_t1 () { local S_NAME_OF_THE_EXECUTABLE=$1 # first function argument local S_TMP_0="\`which $S_NAME_OF_THE_EXECUTABLE 2>/dev/null\`" local S_TMP_1="" local S_TMP_2="S_TMP_1=$S_TMP_0" eval ${S_TMP_2} if [ "$S_TMP_1" == "" ] ; then echo "" echo "This bash script requires the \"$S_NAME_OF_THE_EXECUTABLE\" to be on the PATH." echo "" #---- cd $S_FP_ORIG exit 1 # exit with error fi } # fun_assert_exists_on_path_t1 fun_assert_exists_on_path_t1 "file" # for checking MIME types fun_assert_exists_on_path_t1 "find" # for recursing fun_assert_exists_on_path_t1 "fossil" # tested with v1.34 fun_assert_exists_on_path_t1 "gawk" fun_assert_exists_on_path_t1 "grep" fun_assert_exists_on_path_t1 "cat" fun_assert_exists_on_path_t1 "ruby" # anything over/equal v.2.1 will probably do fun_assert_exists_on_path_t1 "shred" # for secure delete fun_assert_exists_on_path_t1 "uname" # to check the OS type fun_assert_exists_on_path_t1 "uuidgen" "uuid" # for generating tmp file names fun_assert_exists_on_path_t1 "xargs" # find . -name '*' | xargs blabla fun_assert_exists_on_path_t1 "wc" #-------------------------------------------------------------------------- S_TMP_0="`uname -a | grep -E [Ll]inux`" if [ "$S_TMP_0" == "" ]; then echo "" echo " The classical command line utilities at " echo " different operating systems, for example, Linux and BSD," echo " differ. This script is designed to run only on Linux." echo " If You are willing to risk that some of Your data " echo " is deleted and/or Your operating system instance" echo " becomes permanently flawed, to the point that " echo " it will not even boot, then You may edit the Bash script that " echo " displays this error message by modifying the test that " echo " checks for the operating system type." echo "" echo " If You do decide to edit this Bash script, then " echo " a recommendation is to test Your modifications " echo " within a virtual machine or, if virtual machines are not" echo " an option, as some new operating system user that does not have " echo " any access to the vital data/files." echo " GUID=='61782b5c-e018-4acd-95d1-42e0800180e7'" echo "" echo " Aborting script without doing anything." echo "" exit 1 # exit with error fi #-------------------------------------------------------------------------- SB_EXISTS_ON_PATH_T1_RESULT="f" func_sb_exists_on_path_t1 () { ................................................................................ echo "" echo "The Bash function " echo "" echo " func_sb_exists_on_path_t1 " echo "" echo "is not designed to handle an argument that " echo "equals with an empty string." echo "GUID=='13ce522b-56b7-408c-94d1-42e0800180e7'" echo "" #---- cd $S_FP_ORIG exit 1 # exit with error fi local S_TMP_0="`printf \"$S_NAME_OF_THE_EXECUTABLE_1\" | gawk '{gsub(/\s/,"");printf "%s", $1 }'`" if [ "$S_NAME_OF_THE_EXECUTABLE_1" != "$S_TMP_0" ] ; then ................................................................................ echo "The Bash function " echo "" echo " func_sb_exists_on_path_t1 " echo "" echo "is not designed to handle an argument value that contains " echo "spaces or tabulation characters." echo "The received value in parenthesis:($S_NAME_OF_THE_EXECUTABLE_1)." echo "GUID=='2b1a2656-998c-41e0-b1c1-42e0800180e7'" echo "" #---- cd $S_FP_ORIG exit 1 # exit with error fi #-------- S_TMP_0="\`which $S_NAME_OF_THE_EXECUTABLE_1 2>/dev/null\`" ................................................................................ } # func_sb_exists_on_path_t1 #-------------------------------------------------------------------------- S_FUNC_MMMV_GUID_T1_RESULT="not_yet_set" S_FUNC_MMMV_GUID_T1_MODE="" # optim. to skip repeating console tool selection func_mmmv_GUID_t1() { # Does not take any arguments. #-------- #func_mmmv_exc_hash_function_input_verification_t1 "func_mmmv_GUID_t1" "$1" #-------------------- local S_TMP_0="" # declaration local S_TMP_1="" # declaration # Mode selection: ................................................................................ fi #-------- if [ "$S_FUNC_MMMV_GUID_T1_MODE" == "" ] ; then echo "" echo "All of the GUID generation implementations that this script " echo "is capable of using (uuidgen, uuid) " echo "are missing from the PATH." echo "GUID=='5192d656-1e8f-4fd6-93c1-42e0800180e7'" echo "" #---- cd $S_FP_ORIG exit 1 # exit with error fi #-------- if [ "$?" != "0" ]; then echo "" echo "This script is flawed." echo "GUID=='25f74111-7f1d-4197-91c1-42e0800180e7'" echo "" #---- cd $S_FP_ORIG exit 1 # exit with error fi #-------- fi ................................................................................ if [ "$S_FUNC_MMMV_GUID_T1_MODE" == "uuidgen" ]; then S_TMP_0="`uuidgen`" if [ "$?" != "0" ]; then echo "" echo "The console application \"uuidgen\" " echo "exited with an error." echo "" echo "----console--outut--citation--start-----" echo "`uuidgen`" # stdout and stderr echo "----console--outut--citation--end-------" echo "" echo "GUID=='17c8dc2d-8a14-444f-84c1-42e0800180e7'" echo "" #---- cd $S_FP_ORIG exit 1 # exit with error fi #---- S_FUNC_MMMV_GUID_T1_RESULT="$S_TMP_0" ................................................................................ if [ "$S_FUNC_MMMV_GUID_T1_MODE" == "uuid" ]; then S_TMP_0="`uuid`" if [ "$?" != "0" ]; then echo "" echo "The console application \"uuid\" " echo "exited with an error." echo "" echo "----console--outut--citation--start-----" echo "`uuid`" # stdout and stderr echo "----console--outut--citation--end-------" echo "" echo "GUID=='b9e270f1-5720-48d5-bcc1-42e0800180e7'" echo "" #---- cd $S_FP_ORIG exit 1 # exit with error fi #---- S_FUNC_MMMV_GUID_T1_RESULT="$S_TMP_0" ................................................................................ echo "" echo "is something else. The flawed GUID candidate in parenthesis:" echo "($S_FUNC_MMMV_GUID_T1_RESULT)" echo "" echo "The lenght candidate of the flawed GUID candidate in parenthesis:" echo "($S_TMP_0)." echo "" echo "GUID=='cb099b28-40ac-4883-84c1-42e0800180e7'" echo "" #---- cd $S_FP_ORIG exit 1 # exit with error fi #-------------------- } # func_mmmv_GUID_t1 #-------------------------------------------------------------------------- S_TMP_0="" S_ACTIVITY_OF_THIS_SCRIPT=$1 S_URL_REMOTE_REPOSITORY="" SB_EXIT_WITH_ERROR="f" ................................................................................ echo "Aborting script without doing anything." echo "" fi #---- cd $S_FP_ORIG exit 0 } # fun_exit_without_any_errors_t1 #-------------------------------------------------------------------------- # Activity aliases for comfort. if [ "$S_ACTIVITY_OF_THIS_SCRIPT" == "up" ]; then S_ACTIVITY_OF_THIS_SCRIPT="overwrite_remote_with_local" ................................................................................ S_ACTIVITY_OF_THIS_SCRIPT="help" fi if [ "$S_ACTIVITY_OF_THIS_SCRIPT" == "-help" ]; then S_ACTIVITY_OF_THIS_SCRIPT="help" fi #-------- if [ "$S_ACTIVITY_OF_THIS_SCRIPT" == "rm" ]; then S_ACTIVITY_OF_THIS_SCRIPT="shred_local_copy" fi if [ "$S_ACTIVITY_OF_THIS_SCRIPT" == "del" ]; then S_ACTIVITY_OF_THIS_SCRIPT="shred_local_copy" fi if [ "$S_ACTIVITY_OF_THIS_SCRIPT" == "delete" ]; then S_ACTIVITY_OF_THIS_SCRIPT="shred_local_copy" fi #-------- if [ "$S_ACTIVITY_OF_THIS_SCRIPT" == "info" ]; then S_ACTIVITY_OF_THIS_SCRIPT="about" fi if [ "$S_ACTIVITY_OF_THIS_SCRIPT" == "--info" ]; then S_ACTIVITY_OF_THIS_SCRIPT="about" ................................................................................ if [ "$2" != "" ]; then if [ "$2" == "use_autogenerated_commit_message" ]; then if [ "$3" != "" ]; then echo "" echo "If the first console argument is \"overwrite_local_with_remote\" and" echo "the second console argument is \"use_autogenerated_commit_message\", " echo "then there should not be a 3. console argument." echo "GUID=='25ec1eb1-c417-45e4-a3c1-42e0800180e7'" S_ACTIVITY_OF_THIS_SCRIPT="help" SB_EXIT_WITH_ERROR="t" fi else if [ "$2" == "read_commit_message_from_file" ]; then S_FP_MESSAGE_FILE_CANDIDATE="$3" # file path candidate if [ "$S_FP_MESSAGE_FILE_CANDIDATE" == "" ]; then ................................................................................ echo "" echo "If the first console argument is " echo "\"overwrite_local_with_remote\" and" echo "the second console argument is " echo "\"read_commit_message_from_file\", " echo "then there should be also a 3. console argument " echo "that is expected to be a file path to a text file." echo "GUID=='22d36238-7319-44df-94c1-42e0800180e7'" S_ACTIVITY_OF_THIS_SCRIPT="help" SB_EXIT_WITH_ERROR="t" fi if [ "$SB_EXIT_WITH_ERROR" == "f" ]; then if [ "$4" != "" ]; then echo "" echo "If the first console argument is " ................................................................................ echo "the second console argument is " echo "\"read_commit_message_from_file\", " echo "then there should be exactly 3. console arguments, " echo "not 4 or more. Unfortunately the 4. argument is currently " echo "---citation--start---" echo "$4" echo "---citation--end-----" echo "GUID=='82b95a2e-d998-42d9-85b1-42e0800180e7'" S_ACTIVITY_OF_THIS_SCRIPT="help" SB_EXIT_WITH_ERROR="t" fi fi if [ "$SB_EXIT_WITH_ERROR" == "f" ]; then if [ ! -e "$S_FP_MESSAGE_FILE_CANDIDATE" ]; then echo "" echo "The commit message file path candidate " echo "references either a missing file or " echo "a broken symlink." echo "GUID=='2c96ab55-cde4-4f75-83b1-42e0800180e7'" S_ACTIVITY_OF_THIS_SCRIPT="help" SB_EXIT_WITH_ERROR="t" fi fi if [ "$SB_EXIT_WITH_ERROR" == "f" ]; then if [ -d "$S_FP_MESSAGE_FILE_CANDIDATE" ]; then echo "" echo "The commit message file path candidate " echo "references a folder, but it should " echo "reference a text file." echo "GUID=='6033bc44-becc-49dc-b2b1-42e0800180e7'" S_ACTIVITY_OF_THIS_SCRIPT="help" SB_EXIT_WITH_ERROR="t" fi fi if [ "$SB_EXIT_WITH_ERROR" == "f" ]; then S_TMP_0="`filesize $S_FP_MESSAGE_FILE_CANDIDATE`" S_TMP_1="`ruby -e \"s_out='OK'; if (2000<$S_TMP_0) then s_out='too_big' end; print(s_out);\"`" if [ "$S_TMP_1" == "too_big" ]; then echo "" echo "The commit message file path " echo "references a file that has a size of $S_TMP_0 bytes." echo "The suspicion is that it is a wrong file. " echo "because a commit message is usually not that lengthy." echo "GUID=='29330323-2f96-4065-b1b1-42e0800180e7'" S_ACTIVITY_OF_THIS_SCRIPT="help" SB_EXIT_WITH_ERROR="t" else if [ "$S_TMP_0" == "0" ]; then echo "" echo "The commit message file path " echo "references a file that has a size of 0 (zero) bytes." ................................................................................ echo "" echo " \"use_autogenerated_commit_message\"" echo "" echo "in stead of the option " echo "" echo " \"read_commit_message_from_file\" ." echo "" echo "GUID=='8d218548-7102-4c19-b4b1-42e0800180e7'" S_ACTIVITY_OF_THIS_SCRIPT="help" SB_EXIT_WITH_ERROR="t" fi fi fi if [ "$SB_EXIT_WITH_ERROR" == "f" ]; then S_TMP_0="`file --mime-type $S_FP_MESSAGE_FILE_CANDIDATE | grep text `" ................................................................................ echo "The commit message file path " echo "references a file that has a MIME type of " echo "" echo "`file --mime-type $S_FP_MESSAGE_FILE_CANDIDATE`" echo "" echo "The commit message file must be a text file and " echo "text files have the string \"text\" in their MIME type name." echo "GUID=='5b813cf1-4908-45e9-91b1-42e0800180e7'" S_ACTIVITY_OF_THIS_SCRIPT="help" SB_EXIT_WITH_ERROR="t" fi fi fi # read_commit_message_from_file fi fi else if [ "$S_ACTIVITY_OF_THIS_SCRIPT" == "shred_local_copy" ]; then if [ "$2" != "" ]; then # the 2. arg is optional here if [ "$2" != "$S_ARGNAME_ACTIVITY_SHRED_ARG_2" ]; then echo "" echo "If the first console argument is \"shred_local_copy\", then" echo "the second console argument is allowed to be only " echo "" echo " \"$S_ARGNAME_ACTIVITY_SHRED_ARG_2\", without quotation marks." echo "GUID=='666fb445-f5b0-4a7f-92b1-42e0800180e7'" S_ACTIVITY_OF_THIS_SCRIPT="help" SB_EXIT_WITH_ERROR="t" fi fi else if [ "$S_ACTIVITY_OF_THIS_SCRIPT" != "print_script_version" ]; then if [ "$S_ACTIVITY_OF_THIS_SCRIPT" != "help" ]; then echo "" echo "The very first console argument " echo "of this script is expected to be " echo "a command that is specific to this script." echo "GUID=='3b955712-bcfb-44f6-b3b1-42e0800180e7'" S_ACTIVITY_OF_THIS_SCRIPT="help" SB_EXIT_WITH_ERROR="t" fi fi fi fi fi ................................................................................ echo " clone_all <remote repository url>" echo " clone_public <remote repository url>" echo " overwrite_local_with_remote" echo "" echo " overwrite_remote_with_local (use_autogenerated_commit_message)?" echo " overwrite_remote_with_local read_commit_message_from_file <path to a text file>" echo "" echo " shred_local_copy ($S_ARGNAME_ACTIVITY_SHRED_ARG_2)?" echo " help" echo " print_script_version" echo " exit # just for testing" echo "" #---- cd $S_FP_ORIG if [ "$SB_EXIT_WITH_ERROR" == "t" ]; then ................................................................................ # To allow the version to be used as sub-part of file names and # folder names, the version must not contain any spaces, line breaks # and other characters that have a special meaning in Bash. # # If the version ID did not match the GUID regex, then I would have to # write a long comment about it not being allowed to match the # GUID regex. :-D S_VERSION_OF_THIS_SCRIPT="5e72de55-a03d-417b-9cd1-42e0800180e7" if [ "$S_ACTIVITY_OF_THIS_SCRIPT" == "print_script_version" ]; then echo "The version of this script is: $S_VERSION_OF_THIS_SCRIPT" #---- cd $S_FP_ORIG exit 0 fi ................................................................................ fi fi #---- if [ "$SB_THROW" == "t" ]; then echo "" echo "This Bash script is flawed. " echo "fun_assertion_t1() assertion failed." echo "GUID=='29da426c-b117-441e-93b1-42e0800180e7'" echo "" #---- cd $S_FP_ORIG exit 1 fi } # fun_assertion_t1 ................................................................................ echo "The directory " echo "`pwd`" echo "does not contain a Fossil repository file named " echo "" echo " $S_FP_FOSSILFILE_NAME" echo "" echo "Aborting script." echo "GUID=='5950191d-deaf-4abf-a1a1-42e0800180e7'" echo "" #---- cd $S_FP_ORIG exit 1 fi fun_sandbox_folder_or_symlink_exists if [ "$SB_SANDBOX_DIR_EXISTS" == "f" ]; then ................................................................................ echo "The directory " echo "`pwd`" echo "does not contain a directory named " echo "" echo " $S_FP_SANDBOX_DIRECTORY_NAME" echo "" echo "Aborting script." echo "GUID=='653dfc68-75da-4e5b-8ea1-42e0800180e7'" echo "" #---- cd $S_FP_ORIG exit 1 fi } # fun_assert_repository_local_copy_existence ................................................................................ echo "`pwd`" echo "already contain a file named " echo "" echo " $S_FP_FOSSILFILE_NAME" echo "" echo "To avoid overwriting an existing local copy, this script is aborted" echo "and nothing is downloaded/uploaded by this script." echo "GUID=='d6e07f2d-e707-44c5-a5a1-42e0800180e7'" echo "" #---- cd $S_FP_ORIG exit 1 fi if [ "$SB_SANDBOX_DIR_EXISTS" == "t" ]; then echo "" ................................................................................ echo "`pwd`" echo "already contains a directory named " echo "" echo " $S_FP_SANDBOX_DIRECTORY_NAME" echo "" echo "To avoid overwriting an existing local copy, this script is aborted" echo "and nothing is downloaded/uploaded by this script." echo "GUID=='da297b50-e286-423d-93a1-42e0800180e7'" echo "" #---- cd $S_FP_ORIG exit 1 fi } # fun_assert_the_lack_of_repository_local_copy_t1 ................................................................................ #-------------------------------------------------------------------------- fun_last_minute_checks_t1() { # Last minute checks, just to be sure. local S_FP_FORBIDDEN_VALUE=$1 if [ "$S_FP_FORBIDDEN_VALUE" == "/" ]; then echo "" echo "This Bash script is flawed." echo "GUID=='c1d71016-36d5-40de-b4a1-42e0800180e7'" echo "" #---- cd $S_FP_ORIG exit 1 fi if [ "$S_FP_FORBIDDEN_VALUE" == "$HOME" ]; then echo "" echo "This Bash script is flawed." echo "GUID=='4eed6a14-0b10-41a7-8aa1-42e0800180e7'" echo "" #---- cd $S_FP_ORIG exit 1 fi if [ "$S_FP_FORBIDDEN_VALUE" == "/home" ]; then echo "" echo "This Bash script is flawed." echo "GUID=='8e3a2d2e-8602-4a57-a2a1-42e0800180e7'" echo "" #---- cd $S_FP_ORIG exit 1 fi if [ "$S_FP_FORBIDDEN_VALUE" == "/root" ]; then echo "" echo "This Bash script is flawed." echo "GUID=='16d5bccc-3d47-4536-8591-42e0800180e7'" echo "" #---- cd $S_FP_ORIG exit 1 fi if [ "$S_FP_FORBIDDEN_VALUE" == "/etc" ]; then echo "" echo "This Bash script is flawed." echo "GUID=='407a2041-4672-4819-8391-42e0800180e7'" echo "" #---- cd $S_FP_ORIG exit 1 fi if [ "$S_FP_FORBIDDEN_VALUE" == "/usr" ]; then echo "" echo "This Bash script is flawed." echo "GUID=='f121833f-5f5a-4f4b-8391-42e0800180e7'" echo "" #---- cd $S_FP_ORIG exit 1 fi } # fun_last_minute_checks_t1 ................................................................................ fun_folder_is_empty_t1 "$S_FP_DIR" fun_assertion_t1 "$SB_FOLDER_IS_EMPTY" if [ "$SB_FOLDER_IS_EMPTY" == "t" ]; then echo "" echo "This Bash script is flawed. The " echo "$S_FP_DIR" echo "can not possibly be empty, because it contains " echo "at least one file, whcih is " echo "this very same Bash script that outputs the current error message." echo "GUID=='c4a3f01e-dd50-43b5-bf91-42e0800180e7'" echo "" #---- cd $S_FP_ORIG exit 1 fi #-------------------------------------------------------------------------- ................................................................................ SB_SANDBOX_CONTENT_MIGHT_HAVE_BEEN_CHANGED="t" fun_last_minute_checks_t1 "`pwd`" if [ "$S_FP_SANDBOX" == "`pwd`" ]; then rm -fr ./* else echo "" echo "This Bash script is flawed." echo "GUID=='c217ab1a-3f04-4320-b391-42e0800180e7'" echo "" #---- cd $S_FP_ORIG exit 1 fi fi mv -f $S_TMP_FOR_LOCAL/* $S_FP_SANDBOX/ # the -f is for empty source ................................................................................ rm -fr $S_TMP_FOR_LOCAL #---- fun_folder_is_empty_t1 "$S_FP_SANDBOX" if [ "$SB_FOLDER_IS_EMPTY" == "f" ]; then if [ "$S_FP_SANDBOX" != "`pwd`" ]; then echo "" echo "This Bash script is flawed." echo "GUID=='5ddc6156-c835-44f0-a491-42e0800180e7'" echo "" #---- cd $S_FP_ORIG exit 1 fi find . -name '*' | xargs fossil add --force --dotfiles --case-sensitive TRUE SB_SANDBOX_CONTENT_MIGHT_HAVE_BEEN_CHANGED="t" ................................................................................ echo "The file or symlink to it was fine at " echo "the start of this script, it passed the various tests, " echo "but for some reason it got deleted or its target . " echo "got deleted. If the commit message file or" echo "the symlink target resided within the sandbox, then " echo "a recommendation is to use a file that resides " echo "outside of the sandbox." echo "GUID=='549bc742-cdbf-43a6-8291-42e0800180e7'" echo "" #---- cd $S_FP_ORIG exit 1 fi if [ -d "$S_FP_MESSAGE_FILE_CANDIDATE" ]; then # folder or a symlink to a folder echo "" echo "The commit message file path does not reference " echo "a file. It references a folder or a symlink to a folder." echo "The file or symlink to it was fine at " echo "the start of this script, it passed the various tests, " echo "but for some reason there were changes. " echo "GUID=='305146e5-d1d0-41c3-8591-42e0800180e7'" echo "" #---- cd $S_FP_ORIG exit 1 fi cat $S_FP_MESSAGE_FILE_CANDIDATE > $S_TMP_FOR_COMMIT_MESSAGE # else ................................................................................ #---- cd $S_FP_ORIG exit 0 fi # overwrite_remote_with_local #-------------------------------------------------------------------------- if [ "$S_ACTIVITY_OF_THIS_SCRIPT" == "shred_local_copy" ]; then #-------- SB_THERE_IS_SOMETHING_TO_DELETE="f" if [ "$SB_FOSSILFILE_EXISTS" == "t" ]; then SB_THERE_IS_SOMETHING_TO_DELETE="t" fi if [ "$SB_SANDBOX_DIR_EXISTS" == "t" ]; then SB_THERE_IS_SOMETHING_TO_DELETE="t" ................................................................................ # Includes the $2=="" case # id est if the control flow is in here, then there # is a need to prompt for confirmation. # The skipping of the prompt is necessary for # software that use this script as its sub-component. #-------- echo "" echo "The command \"shred_local_copy\" deletes " echo "the repository file, the sandbox and " echo "the associated automatically created archives." echo "" read -p "Proceed with deletion? (Yes/whatever_else) " S_TMP_0 S_TMP_1="`echo $S_TMP_0 | gawk '{print tolower($1)}'`" if [ "$S_TMP_1" == "yes" ]; then echo "" ................................................................................ printf "Deleting ... " else fun_exit_without_any_errors_t1 fi fi fi #-------- if [ "$SB_FOSSILFILE_EXISTS" == "t" ]; then cd $S_FP_DIR # just in case # The shred "-f" option re-sets file access permissions as needed. nice -n10 shred -f --remove $S_FP_FOSSILFILE fi #-------- if [ "$SB_SANDBOX_DIR_EXISTS" == "t" ]; then cd $S_FP_SANDBOX fun_last_minute_checks_t1 "`pwd`" #-------- # The S_TMP_0 is to suppress shred output. S_TMP_0="`find . -name '*' | xargs shred -f --remove 2>/dev/null`" #---- cd $S_FP_DIR # step out of the sandbox directory fun_last_minute_checks_t1 "$S_FP_SANDBOX" chmod -f -R 0700 $S_FP_SANDBOX rm -fr $S_FP_SANDBOX fi #-------- if [ "$SB_ARCHIVE_DIR_EXISTS" == "t" ]; then cd $S_FP_ARCHIVES fun_last_minute_checks_t1 "`pwd`" #-------- # The S_TMP_0 is to suppress shred output. S_TMP_0="`find . -name '*' | xargs shred -f --remove 2>/dev/null`" #---- cd $S_FP_DIR # step out of the archive directory fun_last_minute_checks_t1 "$S_FP_ARCHIVES" chmod -f -R 0700 $S_FP_ARCHIVES rm -fr $S_FP_ARCHIVES fi #-------- if [ "$SB_THERE_IS_SOMETHING_TO_DELETE" == "t" ]; then if [ "$2" != "$S_ARGNAME_ACTIVITY_SHRED_ARG_2" ]; then echo "✓" echo "" fi fi #-------- cd $S_FP_ORIG exit 0 fi # shred_local_copy #-------------------------------------------------------------------------- # All possible actions must have been described # above this code block. echo "" echo "This Bash script is flawed." echo "GUID=='450c2dad-e133-4bc1-8681-42e0800180e7'" echo "" #---- cd $S_FP_ORIG exit 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 ... 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 ... 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 ... 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 ... 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 ... 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 ... 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 ... 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 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 ... 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 .... 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 .... 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 .... 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 .... 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 .... 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 .... 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 .... 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 .... 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 .... 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 .... 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 .... 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 .... 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 .... 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 .... 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 .... 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 .... 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 .... 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 .... 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 .... 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 .... 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 .... 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 |
# Initial author: Martin.Vahi@softf1.com # This file is in the public domain. #========================================================================== S_FP_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" S_FP_ORIG="`pwd`" S_TIMESTAMP="`date +%Y`_`date +%m`_`date +%d`_T_`date +%H`h_`date +%M`min_`date +%S`s" func_assert_exists_on_path_t2 () { local S_NAME_OF_THE_EXECUTABLE_1="$1" # first function argument local S_NAME_OF_THE_EXECUTABLE_2="$2" # optional argument local S_NAME_OF_THE_EXECUTABLE_3="$3" # optional argument local S_NAME_OF_THE_EXECUTABLE_4="$4" # optional argument #-------- # Function calls like # # func_assert_exists_on_path_t2 "" "" "ls" # func_assert_exists_on_path_t2 "ls" "" "ps" # # are not allowed by the spec of this function, but it's OK to call # # func_assert_exists_on_path_t2 "ls" "" # func_assert_exists_on_path_t2 "ls" "ps" "" # func_assert_exists_on_path_t2 "ls" "" "" "" # # local SB_THROW="f" if [ "$S_NAME_OF_THE_EXECUTABLE_1" == "" ] ; then SB_THROW="t" else if [ "$S_NAME_OF_THE_EXECUTABLE_2" == "" ] ; then if [ "$S_NAME_OF_THE_EXECUTABLE_3" != "" ] ; then SB_THROW="t" fi if [ "$S_NAME_OF_THE_EXECUTABLE_4" != "" ] ; then SB_THROW="t" fi else if [ "$S_NAME_OF_THE_EXECUTABLE_3" == "" ] ; then if [ "$S_NAME_OF_THE_EXECUTABLE_4" != "" ] ; then SB_THROW="t" fi fi fi fi #---- if [ "$SB_THROW" == "t" ] ; then echo "" echo "The Bash function " echo "" echo " func_assert_exists_on_path_t2 " echo "" echo "is not designed to handle series of arguments, where " echo "empty strings preced non-empty strings." echo "GUID=='0541255e-4633-4cd9-b55c-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 # exit with error fi if [ "$5" != "" ] ; then echo "" echo "This Bash function is designed to work with at most 4 input arguments" echo "GUID=='41001a45-42a8-4dd3-824c-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 # exit with error fi #-------- # Function calls like # # func_assert_exists_on_path_t2 " " # func_assert_exists_on_path_t2 "ls ps" # contains a space # # are not allowed. SB_THROW="f" local S_TMP_0="" local S_TMP_1="" local S_TMP_2="" #---- if [ "$SB_THROW" == "f" ] ; then S_TMP_0="`printf \"$S_NAME_OF_THE_EXECUTABLE_1\" | gawk '{gsub(/\s/,"");printf "%s", $1 }'`" if [ "$S_NAME_OF_THE_EXECUTABLE_1" != "$S_TMP_0" ] ; then SB_THROW="t" S_TMP_1="$S_NAME_OF_THE_EXECUTABLE_1" S_TMP_2="GUID=='2a1fd3d0-3841-4e87-854c-f1e0305090e7'" fi fi #---- if [ "$SB_THROW" == "f" ] ; then S_TMP_0="`printf \"$S_NAME_OF_THE_EXECUTABLE_2\" | gawk '{gsub(/\s/,"");printf "%s", $1 }'`" if [ "$S_NAME_OF_THE_EXECUTABLE_2" != "$S_TMP_0" ] ; then SB_THROW="t" S_TMP_1="$S_NAME_OF_THE_EXECUTABLE_2" S_TMP_2="GUID=='d23cd2de-f38c-43f2-894c-f1e0305090e7'" fi fi #---- if [ "$SB_THROW" == "f" ] ; then S_TMP_0="`printf \"$S_NAME_OF_THE_EXECUTABLE_3\" | gawk '{gsub(/\s/,"");printf "%s", $1 }'`" if [ "$S_NAME_OF_THE_EXECUTABLE_3" != "$S_TMP_0" ] ; then SB_THROW="t" S_TMP_1="$S_NAME_OF_THE_EXECUTABLE_3" S_TMP_2="GUID=='7bf6f543-26c4-400e-a33c-f1e0305090e7'" fi fi #---- if [ "$SB_THROW" == "f" ] ; then S_TMP_0="`printf \"$S_NAME_OF_THE_EXECUTABLE_4\" | gawk '{gsub(/\s/,"");printf "%s", $1 }'`" if [ "$S_NAME_OF_THE_EXECUTABLE_4" != "$S_TMP_0" ] ; then SB_THROW="t" S_TMP_1="$S_NAME_OF_THE_EXECUTABLE_4" S_TMP_2="GUID=='a8746d54-43bc-4958-923c-f1e0305090e7'" fi fi #-------- if [ "$SB_THROW" == "t" ] ; then echo "" echo "The Bash function " echo "" echo " func_assert_exists_on_path_t2 " echo "" echo "is not designed to handle an argument value that contains " echo "spaces or tabulation characters." echo "The unaccepted value in parenthesis:($S_TMP_1)." echo "Branch $S_TMP_2." echo "GUID=='c3948131-401e-470a-a53c-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 # exit with error fi SB_THROW="f" # Just a reset, should I forget to reset it later. #--------------- S_TMP_0="\`which $S_NAME_OF_THE_EXECUTABLE_1 2>/dev/null\`" local S_TMP_1="" local S_TMP_2="S_TMP_1=$S_TMP_0" eval ${S_TMP_2} #---- if [ "$S_TMP_1" == "" ] ; then if [ "$S_NAME_OF_THE_EXECUTABLE_2" == "" ] ; then if [ "$S_NAME_OF_THE_EXECUTABLE_3" == "" ] ; then if [ "$S_NAME_OF_THE_EXECUTABLE_4" == "" ] ; then echo "" echo "This bash script requires the \"$S_NAME_OF_THE_EXECUTABLE_1\" to be on the PATH." echo "GUID=='f284925c-b40f-4549-b22c-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 # exit with error fi fi fi else return # at least one of the programs was available at the PATH fi #-------- S_TMP_0="\`which $S_NAME_OF_THE_EXECUTABLE_2 2>/dev/null\`" S_TMP_1="" S_TMP_2="S_TMP_1=$S_TMP_0" eval ${S_TMP_2} #---- if [ "$S_TMP_1" == "" ] ; then if [ "$S_NAME_OF_THE_EXECUTABLE_3" == "" ] ; then if [ "$S_NAME_OF_THE_EXECUTABLE_4" == "" ] ; then echo "" echo "This bash script requires that either \"$S_NAME_OF_THE_EXECUTABLE_1\" or " echo " \"$S_NAME_OF_THE_EXECUTABLE_2\" is available on the PATH." echo "GUID=='7f92b447-d805-460e-912c-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 # exit with error fi fi else return # at least one of the programs was available at the PATH fi #-------- S_TMP_0="\`which $S_NAME_OF_THE_EXECUTABLE_3 2>/dev/null\`" S_TMP_1="" S_TMP_2="S_TMP_1=$S_TMP_0" eval ${S_TMP_2} #---- if [ "$S_TMP_1" == "" ] ; then if [ "$S_NAME_OF_THE_EXECUTABLE_4" == "" ] ; then echo "" echo "This bash script requires that either \"$S_NAME_OF_THE_EXECUTABLE_1\" or " echo " \"$S_NAME_OF_THE_EXECUTABLE_2\" or \"$S_NAME_OF_THE_EXECUTABLE_3\" " echo "is available on the PATH." echo "GUID=='39c63c1f-eec1-450d-b12c-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 # exit with error fi else return # at least one of the programs was available at the PATH fi #-------- S_TMP_0="\`which $S_NAME_OF_THE_EXECUTABLE_4 2>/dev/null\`" S_TMP_1="" S_TMP_2="S_TMP_1=$S_TMP_0" eval ${S_TMP_2} #---- if [ "$S_TMP_1" == "" ] ; then echo "" echo "This bash script requires that either \"$S_NAME_OF_THE_EXECUTABLE_1\" or " echo " \"$S_NAME_OF_THE_EXECUTABLE_2\" or \"$S_NAME_OF_THE_EXECUTABLE_3\" or " echo " \"$S_NAME_OF_THE_EXECUTABLE_4\" is available on the PATH." echo "GUID=='71c5f5de-2801-47fc-841c-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 # exit with error else return # at least one of the programs was available at the PATH fi #-------- } # func_assert_exists_on_path_t2 func_assert_exists_on_path_t2 "cat" func_assert_exists_on_path_t2 "file" # for checking MIME types func_assert_exists_on_path_t2 "find" # for recursing func_assert_exists_on_path_t2 "fossil" # tested with v1.34 func_assert_exists_on_path_t2 "gawk" func_assert_exists_on_path_t2 "grep" func_assert_exists_on_path_t2 "nice" func_assert_exists_on_path_t2 "ruby" # anything over/equal v.2.1 will probably do func_assert_exists_on_path_t2 "shred" "gshred" "rm" # for shredding, if possible func_assert_exists_on_path_t2 "uname" # to check the OS type func_assert_exists_on_path_t2 "uuidgen" "uuid" # for generating tmp file names func_assert_exists_on_path_t2 "xargs" # find . -name '*' | xargs blabla func_assert_exists_on_path_t2 "wc" #-------------------------------------------------------------------------- S_FUNC_MMMV_OPERATING_SYSTEM_TYPE_T1_RESULT="" func_mmmv_operating_system_type_t1() { if [ "$S_FUNC_MMMV_OPERATING_SYSTEM_TYPE_T1_RESULT" == "" ]; then S_TMP_0="`uname -a | grep -E [Ll]inux`" if [ "$S_TMP_0" != "" ]; then S_FUNC_MMMV_OPERATING_SYSTEM_TYPE_T1_RESULT="Linux" else S_TMP_0="`uname -a | grep BSD `" if [ "$S_TMP_0" != "" ]; then S_FUNC_MMMV_OPERATING_SYSTEM_TYPE_T1_RESULT="BSD" else S_FUNC_MMMV_OPERATING_SYSTEM_TYPE_T1_RESULT="undetermined" fi fi fi } # func_mmmv_operating_system_type_t1 func_mmmv_operating_system_type_t1 if [ "$S_FUNC_MMMV_OPERATING_SYSTEM_TYPE_T1_RESULT" != "Linux" ]; then if [ "$S_FUNC_MMMV_OPERATING_SYSTEM_TYPE_T1_RESULT" != "BSD" ]; then echo "" echo " The classical command line utilities at " echo " different operating systems, for example, Linux and BSD," echo " differ. This script is designed to run only on " echo " Linux and some BSD variants." echo " If You are willing to risk that some of Your data " echo " is deleted and/or Your operating system instance" echo " becomes permanently flawed, to the point that " echo " it will not even boot, then You may edit the Bash script that " echo " displays this error message by modifying the test that " echo " checks for the operating system type." echo "" echo " If You do decide to edit this Bash script, then " echo " a recommendation is to test Your modifications " echo " within a virtual machine or, if virtual machines are not" echo " an option, as some new operating system user that does not have " echo " any access to the vital data/files." echo " GUID=='52460304-7c62-4f4e-b51c-f1e0305090e7'" echo "" echo " Aborting script without doing anything." echo "" exit 1 # exit with error fi fi #-------------------------------------------------------------------------- SB_EXISTS_ON_PATH_T1_RESULT="f" func_sb_exists_on_path_t1 () { ................................................................................ echo "" echo "The Bash function " echo "" echo " func_sb_exists_on_path_t1 " echo "" echo "is not designed to handle an argument that " echo "equals with an empty string." echo "GUID=='31ed2a21-41ac-4368-831c-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 # exit with error fi local S_TMP_0="`printf \"$S_NAME_OF_THE_EXECUTABLE_1\" | gawk '{gsub(/\s/,"");printf "%s", $1 }'`" if [ "$S_NAME_OF_THE_EXECUTABLE_1" != "$S_TMP_0" ] ; then ................................................................................ echo "The Bash function " echo "" echo " func_sb_exists_on_path_t1 " echo "" echo "is not designed to handle an argument value that contains " echo "spaces or tabulation characters." echo "The received value in parenthesis:($S_NAME_OF_THE_EXECUTABLE_1)." echo "GUID=='40cb1b02-90f3-404e-8a0c-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 # exit with error fi #-------- S_TMP_0="\`which $S_NAME_OF_THE_EXECUTABLE_1 2>/dev/null\`" ................................................................................ } # func_sb_exists_on_path_t1 #-------------------------------------------------------------------------- S_FUNC_MMMV_GUID_T1_RESULT="not_yet_set" S_FUNC_MMMV_GUID_T1_MODE="" # optim. to skip repeating console tool selection func_mmmv_GUID_t1() { # Does not take any arguments. #-------- #func_mmmv_exc_hash_function_input_verification_t1 "func_mmmv_GUID_t1" "$1" #-------------------- local S_TMP_0="" # declaration local S_TMP_1="" # declaration # Mode selection: ................................................................................ fi #-------- if [ "$S_FUNC_MMMV_GUID_T1_MODE" == "" ] ; then echo "" echo "All of the GUID generation implementations that this script " echo "is capable of using (uuidgen, uuid) " echo "are missing from the PATH." echo "GUID=='3094c835-5f40-4884-b40c-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 # exit with error fi #-------- if [ "$?" != "0" ]; then echo "" echo "This script is flawed." echo "GUID=='817cc031-3315-4771-a3fb-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 # exit with error fi #-------- fi ................................................................................ if [ "$S_FUNC_MMMV_GUID_T1_MODE" == "uuidgen" ]; then S_TMP_0="`uuidgen`" if [ "$?" != "0" ]; then echo "" echo "The console application \"uuidgen\" " echo "exited with an error." echo "" echo "----console--output--citation--start-----" echo "`uuidgen`" # stdout and stderr echo "----console--output--citation--end-------" echo "" echo "GUID=='46b00d44-8784-489e-a5fb-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 # exit with error fi #---- S_FUNC_MMMV_GUID_T1_RESULT="$S_TMP_0" ................................................................................ if [ "$S_FUNC_MMMV_GUID_T1_MODE" == "uuid" ]; then S_TMP_0="`uuid`" if [ "$?" != "0" ]; then echo "" echo "The console application \"uuid\" " echo "exited with an error." echo "" echo "----console--output--citation--start-----" echo "`uuid`" # stdout and stderr echo "----console--output--citation--end-------" echo "" echo "GUID=='c3d42e43-1f05-4355-93fb-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 # exit with error fi #---- S_FUNC_MMMV_GUID_T1_RESULT="$S_TMP_0" ................................................................................ echo "" echo "is something else. The flawed GUID candidate in parenthesis:" echo "($S_FUNC_MMMV_GUID_T1_RESULT)" echo "" echo "The lenght candidate of the flawed GUID candidate in parenthesis:" echo "($S_TMP_0)." echo "" echo "GUID=='4bba14f5-f666-40a4-9efb-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 # exit with error fi #-------------------- } # func_mmmv_GUID_t1 #-------------------------------------------------------------------------- S_FUNC_MMMV_SHRED_T1_MODE="" # optim. to skip repeating console tool selection func_mmmv_shred_t1() { local S_FP_IN="$1" # path to the file or folder to be shredded # The next input parameter is a shoddy compromise, # for the case, where shred/gshred is not installed: local SB_OK_TO_USE_RM_IF_SHREDDING_APPS_NOT_AVAILABLE="$2" # domain: {"","f","t"} #-------------------- if [ "$SB_OK_TO_USE_RM_IF_SHREDDING_APPS_NOT_AVAILABLE" != "" ] ; then if [ "$SB_OK_TO_USE_RM_IF_SHREDDING_APPS_NOT_AVAILABLE" != "t" ] ; then if [ "$SB_OK_TO_USE_RM_IF_SHREDDING_APPS_NOT_AVAILABLE" != "f" ] ; then echo "" echo "The second parameter of this function, the " echo "" echo " SB_OK_TO_USE_RM_IF_SHREDDING_APPS_NOT_AVAILABLE(==$SB_OK_TO_USE_RM_IF_SHREDDING_APPS_NOT_AVAILABLE)" echo "" echo "is optional, but its range is {\"\",\"f\",\"t\"}," echo "without the quotation marks." echo "GUID=='502df336-4c86-4286-83fb-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 # exit with error fi fi else # $SB_OK_TO_USE_RM_IF_SHREDDING_APPS_NOT_AVAILABLE == "" SB_OK_TO_USE_RM_IF_SHREDDING_APPS_NOT_AVAILABLE="f" fi #-------------------- # Declarations: local SB_THROW="" local SB_USE_RUBY="" local S_CMD="" local S_GUID="" local S_TMP_0="" local S_TMP_1="" local S_TMP_2="" local SI_0="-9999" local SI_1="-9999" local S_SHREDDER_APPLICATION_NAME="" local S_FP_PWD_BEFORE_SHREDDING="" #-------------------- # Mode selection: if [ "$S_FUNC_MMMV_SHRED_T1_MODE" == "" ] ; then SB_EXISTS_ON_PATH_T1_RESULT="f" # if-block init #---- if [ "$SB_EXISTS_ON_PATH_T1_RESULT" == "f" ] ; then S_TMP_0="shred" # Linux version func_sb_exists_on_path_t1 "$S_TMP_0" if [ "$SB_EXISTS_ON_PATH_T1_RESULT" == "t" ] ; then S_FUNC_MMMV_SHRED_T1_MODE="$S_TMP_0" fi fi #---- if [ "$SB_EXISTS_ON_PATH_T1_RESULT" == "f" ] ; then S_TMP_0="gshred" # BSD version func_sb_exists_on_path_t1 "$S_TMP_0" if [ "$SB_EXISTS_ON_PATH_T1_RESULT" == "t" ] ; then S_FUNC_MMMV_SHRED_T1_MODE="$S_TMP_0" fi fi #---- if [ "$SB_EXISTS_ON_PATH_T1_RESULT" == "f" ] ; then if [ "$SB_OK_TO_USE_RM_IF_SHREDDING_APPS_NOT_AVAILABLE" == "t" ] ; then S_TMP_0="rm" # a shoddy compromise version for exeptional cases func_sb_exists_on_path_t1 "$S_TMP_0" if [ "$SB_EXISTS_ON_PATH_T1_RESULT" == "t" ] ; then func_mmmv_operating_system_type_t1 if [ "$S_FUNC_MMMV_OPERATING_SYSTEM_TYPE_T1_RESULT" != "BSD" ]; then S_FUNC_MMMV_SHRED_T1_MODE="rm_BSD" else # Linux and all the rest S_FUNC_MMMV_SHRED_T1_MODE="rm_plain" fi else echo "" echo "Something is wrong at the operating system " echo "environment setup. All UNIX-like operating systems " echo "and their emulators " echo "are expected to have the \"rm\" command." echo "" echo " \$(which rm)==\"`which rm`\"" echo "" echo " PATH=$PATH" # will be a huge string echo "" echo "GUID=='a6e67041-a70f-4e87-92fb-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 # exit with error fi fi fi #-------- if [ "$S_FUNC_MMMV_SHRED_T1_MODE" == "" ] ; then echo "" echo "All of the file shredding implementations that this script " echo "is capable of using (shred, gshred) " echo "are missing from the PATH." echo "GUID=='2db9ac59-a8f0-4852-a1eb-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 # exit with error fi #-------- if [ "$?" != "0" ]; then echo "" echo "This script is flawed." echo "GUID=='4a9e0e43-a179-434b-81eb-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 # exit with error fi #-------- fi #-------------------- S_TMP_0=$(echo $S_FP_IN | gawk '{gsub(/^[\/]/,""); printf "%s",$1 }') if [ "$S_TMP_0" == "$S_FP_IN" ]; then echo "" echo "The path is expected to be an absolute path, " echo "but currently it is not." echo " S_FP_IN==$S_FP_IN" echo "GUID=='b72d3528-b829-43dd-b4eb-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 # exit with an error fi #-------- if [ -h $S_FP_IN ]; then # The control flow is in here regardless of # whether the symbolic link is broken or not. # If the path is to a non-existing file/link/folder, # then the control flow will not enter this branch. echo "" echo "The " echo " S_FP_IN=$S_FP_IN" echo "is a symbolic link, but it is expected to " echo "be a file or a folder." echo "GUID=='2ff01c25-3734-48c8-a9eb-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 # exit with error fi if [ ! -e $S_FP_IN ]; then echo "" echo "The " echo " S_FP_IN=$S_FP_IN" echo "does not exist." echo "GUID=='2b88f713-2945-4752-a4eb-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 # exit with error fi #-------- if [ -d $S_FP_IN ]; then #--------start--of--sub-path--check---- # If the $S_FP_IN is a folder, then the `pwd` # should not be a sub-path or a path of the # folder that is being deleted. S_TMP_0="`cd $S_FP_IN;pwd`/" S_TMP_1="`pwd`/" #---- if [ "$S_TMP_0" == "$S_TMP_1" ]; then if [ ! -d $S_FP_IN ]; then echo "" echo "This Bash script is flawed. " echo " S_FP_IN=$S_FP_IN" echo "GUID=='5b46db54-09a9-41ab-b5eb-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 fi #---- echo "" echo "The working directory, " echo "" echo " PWD=$PWD" echo "" echo "equals with the folder that is being deleted." echo "" echo " S_TMP_0=$S_TMP_0" echo "" echo " S_FP_IN=$S_FP_IN" echo "" echo "GUID=='167f9421-0412-433c-91db-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 # exit with error fi #---- # If the normalized $S_FP_IN is a folder and # the "`pwd`/" is shorter than the normalized $S_FP_IN, then, # with the exceptions of some symbolic links, # the "`pwd`/" can not be equal to the normalized $S_FP_IN, # nor can the "`pwd`/" be a folder that is a sub-folder # of the $S_FP_IN. # # The paht lenght code is: # # SI_0="` echo \"$S_TMP_0\" | gawk '{i=length;printf "%s", i }' `" # S_FP_IN # SI_1="` echo \"$S_TMP_1\" | gawk '{i=length;printf "%s", i }' `" # pwd # if [ "$SI_0" -lt "$SI_1" ]; then # $SI_0 < $SI_1 # #echo "$SI_0 < $SI_1" # # # # In here the length of the normalized form of the $S_FP_IN # # is shorter than the "`pwd`/" and therefore the working directory # # has a greater probability to be at a sub-path of the $S_FP_IN. # # < # A lot of Ruby code, because # the gawk code will have trouble with folders that # contain spaces and other special characters # > # fi # # but unfortunately the Ruby code that uses # temporary files and the String.index would be # unstable due to the # # https://bugs.ruby-lang.org/issues/12710 # https://archive.is/AJpgL # # Add to that the fact that this Bash function # would be much more appealing, if it did not launch # any 40BiB sized interpreters like the Ruby interpreter (in 2016) # and the temptation to just skip testing, whether the # working directory (`pwd`) resides at a directory that # is a sub-path of the $S_FP_IN, grows even higher. # So, for the time being that check is omitted from here. # # TODO: If the year is at least 2020, then try to find out, # whether there's some elegant way to implement that check. # # A code fragment for later consideration: # S_TMP_2="`echo \"$S_TMP_0\" | gawk '{gsub(/\s/,\"NotASpace\");printf \"%s\", \$1 }' `" # if [ "$S_TMP_2" != "$S_TMP_0" ]; then # # S_TMP_0 contains strings # SB_USE_RUBY="t" # fi #--------end--of--sub-path--check---- fi #-------------------- S_FP_PWD_BEFORE_SHREDDING="`pwd`" S_CMD="" # to be sure #-------------------- S_TMP_0="cd $S_FP_IN ; nice -n10 find . -name '*' | nice -n10 xargs " # The space after the "cd $S_FP_IN" and before the ";" is compulsory. #---- # The "2>/dev/null" after the shredding/deletion command # is to hide the file permissions related error messages. # The failure is detected by studying file existence. #-------------------- if [ "$S_FUNC_MMMV_SHRED_T1_MODE" == "shred" ]; then S_SHREDDER_APPLICATION_NAME="shred" if [ -d $S_FP_IN ]; then S_CMD="$S_TMP_0 \ $S_SHREDDER_APPLICATION_NAME -f --remove 2>/dev/null " else S_CMD="nice -n10 $S_SHREDDER_APPLICATION_NAME -f --remove $S_FP_IN 2>/dev/null " fi fi #---- if [ "$S_FUNC_MMMV_SHRED_T1_MODE" == "gshred" ]; then S_SHREDDER_APPLICATION_NAME="gshred" if [ -d $S_FP_IN ]; then S_CMD="$S_TMP_0 \ $S_SHREDDER_APPLICATION_NAME --force --iterations=2 --remove -z 2>/dev/null " else S_CMD="nice -n10 \ $S_SHREDDER_APPLICATION_NAME --force --iterations=2 --remove -z $S_FP_IN 2>/dev/null " fi fi #---- # The "rm" on Linux and BSD differ, # a bit like the "ps" # on Linux and BSD differ. # The "rm -f -P foo" overwrites the file with NON-random # values before deleting. # The "rm -f foo" works, whenever the "rm" is called by the file owner. # The "rm -f -P foo" requires write permissions even, # if the "rm" is called by the file owner. if [ "$S_FUNC_MMMV_SHRED_T1_MODE" == "rm_BSD" ]; then S_SHREDDER_APPLICATION_NAME="rm" if [ -d $S_FP_IN ]; then S_CMD="$S_TMP_0 \ $S_SHREDDER_APPLICATION_NAME -f -P $S_FP_IN 2>/dev/null " else S_CMD="nice -n10 $S_SHREDDER_APPLICATION_NAME -f -P $S_FP_IN 2>/dev/null " fi fi if [ "$S_FUNC_MMMV_SHRED_T1_MODE" == "rm_plain" ]; then # The "rm -f foo" seems to be universally available # at all UNIX-like environments. S_SHREDDER_APPLICATION_NAME="rm" if [ -d $S_FP_IN ]; then S_CMD="$S_TMP_0 \ $S_SHREDDER_APPLICATION_NAME -f $S_FP_IN 2>/dev/null " else S_CMD="nice -n10 $S_SHREDDER_APPLICATION_NAME -f $S_FP_IN 2>/dev/null " fi fi #-------------------- eval "$S_CMD" # the "eval" is required due to the command "find" cd $S_FP_PWD_BEFORE_SHREDDING # required if the $S_FP_IN was a folder if [ -e $S_FP_IN ]; then # If the control flow is here, then the $S_FP_IN was # a folder or the deletion failed or both. chmod -f -R 0700 $S_FP_IN # chmod 0777 would introduce s security flaw eval "$S_CMD" # the "eval" is required due to the command "find" cd $S_FP_PWD_BEFORE_SHREDDING #---- SB_THROW="f" if [ -d $S_FP_IN ]; then S_TMP_0="`cd $S_FP_IN; pwd`" # "./home///foo" -> "/home/foo" # Checks are intentionally missing to # allow this Bash function to be universal, without exceptions. #---- cd $S_TMP_0 S_TMP_1="`find . -name '*' | \ xargs file --mime-type | \ grep -v directory | grep -v folder `" # The file --mime-type foo # works on both, Linux and BSD. cd $S_FP_PWD_BEFORE_SHREDDING #---- if [ "$S_TMP_1" == "" ]; then rm -fr $S_TMP_0 else SB_THROW="t" S_GUID="'23c2b1e5-3972-4dc6-a2db-f1e0305090e7'" fi fi #---- if [ "$SB_THROW" == "f" ]; then # to avoid overwriting the S_GUID if [ -e $S_FP_IN ]; then SB_THROW="t" S_GUID="'ca0b9b36-4ea9-4be6-92db-f1e0305090e7'" fi fi if [ "$SB_THROW" == "t" ]; then echo "" echo "The deletion failed even after the " echo "" echo " chmod -f -R 0700 $S_FP_IN " echo "" echo "The " echo "" echo " chmod 0777 " echo "" echo "is not done automatically in this " echo "Bash function, because " echo "it might introduce a security flaw." echo "" echo " S_FUNC_MMMV_SHRED_T1_MODE=$S_FUNC_MMMV_SHRED_T1_MODE" echo "" echo " S_CMD=$S_CMD" echo "" echo "GUID==$S_GUID" echo "GUID=='73d84042-9e60-4316-b3db-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 # exit with error fi fi S_GUID="'693c9923-46d0-4603-92db-f1e0305090e7'" #counters S_GUID related flaws #-------------------- if [ -e $S_FP_IN ]; then echo "" echo "The deletion of the " echo " S_FP_IN=$S_FP_IN" echo "failed or the file or folder was re-created by " echo "some other process before this file existance check." echo "GUID=='4c690312-7d59-43db-95cb-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 # exit with error fi #-------------------- cd $S_FP_PWD_BEFORE_SHREDDING } # func_mmmv_shred_t1 #-------------------------------------------------------------------------- S_TMP_0="" S_ACTIVITY_OF_THIS_SCRIPT=$1 S_URL_REMOTE_REPOSITORY="" SB_EXIT_WITH_ERROR="f" ................................................................................ echo "Aborting script without doing anything." echo "" fi #---- cd $S_FP_ORIG exit 0 } # fun_exit_without_any_errors_t1 #-------------------------------------------------------------------------- SB_FUNC_MMMV_ASSERT_FILE_PATHS_DIFFER_T1_ASSERTION_FAILED="f" func_mmmv_assert_file_paths_differ_t1(){ local S_FP_0="$1" local S_FP_1="$2" local S_GUID="$3" local SB_DO_NOT_TRHOW_ON_ASSERTION_FAILURE="$4" # domain: {"","f","t"} #-------- if [ "$SB_DO_NOT_TRHOW_ON_ASSERTION_FAILURE" != "" ] ; then if [ "$SB_DO_NOT_TRHOW_ON_ASSERTION_FAILURE" != "t" ] ; then if [ "$SB_DO_NOT_TRHOW_ON_ASSERTION_FAILURE" != "f" ] ; then echo "" echo "The fourth parameter of this function, the " echo "" echo " SB_DO_NOT_TRHOW_ON_ASSERTION_FAILURE(==$SB_DO_NOT_TRHOW_ON_ASSERTION_FAILURE)" echo "" echo "is optional, but its range is {\"\",\"f\",\"t\"}," echo "without the quotation marks." echo "GUID=='55200d1b-73f9-46a3-82cb-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 # exit with error fi fi else # $SB_DO_NOT_TRHOW_ON_ASSERTION_FAILURE == "" SB_DO_NOT_TRHOW_ON_ASSERTION_FAILURE="f" fi SB_FUNC_MMMV_ASSERT_FILE_PATHS_DIFFER_T1_ASSERTION_FAILED="f" # global #-------- # The block of if-else statements for comparing the 2 paths # is so error prone to write that this function is written # according to a schematic that resides at: # http://longterm.softf1.com/documentation_fragments/2016_09_03_comparison_of_file_paths_t1/ # https://archive.is/R4yw9 #-------- # Declarations: local S_GUID_CRAWL="S_GUID_CRAWL not set" # tree crawling at the schematic local S_GUID_CMP="S_GUID_CMP not set" # comparison at tree leaf # Some leaves are equivalent. local S_COMPARISON_MODE="" local SB_THROW="f" local SB_ASSERTION_FAILED="f" local SB_STR0="f" # whether S_FP_0 is compared purely as a string local SB_STR1="f" # whether S_FP_1 is compared purely as a string local S_FP_0_STR="$S_FP_0" local S_FP_1_STR="$S_FP_1" local S_FP_X="" # a temporary variable for holding path value local S_RUBY_SRC_0="" #-------- if [ "$S_FP_0" == "$S_FP_1" ]; then # Covers also the case, where both are existing # folders, but the paths to them contains "../". # By making the string comparison to be the first thing tried # a few file system accesses might be saved. SB_ASSERTION_FAILED="t" S_GUID_CRAWL="644d292d-c01e-47d0-855c-f1e0305090e7" S_GUID_CMP="57bc9b05-da56-4eff-954c-f1e0305090e7" else # the rest of the 3 comparison modes #-------- if [ -e $S_FP_0 ]; then if [ -d $S_FP_0 ]; then if [ -e $S_FP_1 ]; then if [ -d $S_FP_1 ]; then S_COMPARISON_MODE="cmode_cd0_cd1" else S_COMPARISON_MODE="cmode_cd0_str1" SB_STR1="t" fi else S_COMPARISON_MODE="cmode_cd0_str1" SB_STR1="t" fi else if [ -e $S_FP_1 ]; then if [ -d $S_FP_1 ]; then S_COMPARISON_MODE="cmode_str0_cd1" SB_STR0="t" else S_COMPARISON_MODE="cmode_str0_str1" SB_STR0="t" SB_STR1="t" fi else S_COMPARISON_MODE="cmode_str0_str1" SB_STR0="t" SB_STR1="t" fi fi else # $S_FP_0 is missing or it is a broken symbolic link if [ -e $S_FP_1 ]; then if [ -d $S_FP_1 ]; then S_COMPARISON_MODE="cmode_str0_cd1" SB_STR0="t" else S_COMPARISON_MODE="cmode_str0_str1" SB_STR0="t" SB_STR1="t" fi else S_COMPARISON_MODE="cmode_str0_str1" SB_STR0="t" SB_STR1="t" fi fi #---------------- # The "cmode_str0_str1" was tried # at the first if-clause of the block, but # that does not catch equivalent cases like # # S_FP_0="`pwd`/././////a_nonexisting_file_or_folder" # S_FP_1="`pwd`/a_nonexisting_file_or_folder" # # S_FP_0="./a_nonexisting_file_or_folder" # S_FP_1="././././././a_nonexisting_file_or_folder" # # S_FP_0="/a_nonexisting_file_or_folder" # S_FP_1="/////a_nonexisting_file_or_folder" # # S_FP_0="/a_nonexisting_file_or_folder" # S_FP_1="/..///../a_nonexisting_file_or_folder" # # String normalization is required whenever at least # one of the paths is used at comparison # purely as a string. # #----start-of-Ruby-script-header--for-copy/pasting---- # #!/usr/bin/env ruby # # s_fp_0="./a_nonexisting_file_or_folder" # s_fp_1="././..//../.././a_nonexisting_file_or_folder" # # # The path "/../foo" is equivalent to "/foo". # s_fp_2="/././..//../.././a_nonexisting_file_or_folder" # # # This script does not cover the case, # # where "./aa/../bb" is equivalent to "./bb" #----end---of-Ruby-script-header-for-copy/pasting---- S_RUBY_SRC_0="\ s_0='';\ s_1=ARGV[0].to_s;\ rgx_0=/[\\/][.][\\/]/;\ rgx_1=/^[.][\\/]/;\ rgx_2=/^[\\/][.][.][\\/]/;\ i_4safety=0;\ while s_0!=s_1 do ;\ s_0=s_1;\ s_1=s_0.gsub(rgx_0,'/');\ i_4safety=i_4safety+1;\ if 10000<i_4safety then ;\ raise(Exception.new('boo'));\ end;\ end ;\ s_0=s_1;\ s_1=s_0.gsub(rgx_1,'');\ s_0=s_1;\ s_1=s_0.gsub(/[\\/]+/,'/');\ ;\ ;\ i_4safety=0;\ while s_0!=s_1 do ;\ s_0=s_1;\ s_1=s_0.gsub(rgx_2,'/');\ i_4safety=i_4safety+1;\ if 10000<i_4safety then ;\ raise(Exception.new('10b7aae4-1940-4361-a4cb-f1e0305090e7'));\ end;\ end ;\ s_0=s_1;\ s_1=s_0.gsub(rgx_1,'');\ s_0=s_1;\ s_1=s_0.gsub(/[\\/]+/,'/');\ ;\ print s_1;\ " #---- if [ "$SB_STR0" == "t" ]; then S_FP_0_STR="`ruby -e \"$S_RUBY_SRC_0\" $S_FP_0`" fi if [ "$SB_STR1" == "t" ]; then S_FP_1_STR="`ruby -e \"$S_RUBY_SRC_0\" $S_FP_1`" fi #---------------- if [ "$S_COMPARISON_MODE" == "cmode_cd0_str1" ]; then # 2 cases at the schematic S_FP_X="`cd $S_FP_0;pwd`" if [ "$S_FP_X" == "$S_FP_1_STR" ]; then SB_ASSERTION_FAILED="t" S_GUID_CMP="3a6056a5-c267-4111-b24c-f1e0305090e7" fi if [ "$SB_ASSERTION_FAILED" != "t" ]; then if [ "$S_FP_X" == "$S_FP_1" ]; then # just in case SB_ASSERTION_FAILED="t" S_GUID_CMP="57a656e5-aa92-40a8-a53c-f1e0305090e7" fi fi else if [ "$S_COMPARISON_MODE" == "cmode_str0_cd1" ]; then # 2 cases at the schematic S_FP_X="`cd $S_FP_1;pwd`" if [ "$S_FP_0_STR" == "$S_FP_X" ]; then SB_ASSERTION_FAILED="t" S_GUID_CMP="2bc33092-26d1-4787-953c-f1e0305090e7" fi if [ "$SB_ASSERTION_FAILED" != "t" ]; then if [ "$S_FP_0" == "$S_FP_X" ]; then # just in case SB_ASSERTION_FAILED="t" S_GUID_CMP="05494129-51a8-4d7d-923c-f1e0305090e7" fi fi else if [ "$S_COMPARISON_MODE" == "cmode_cd0_cd1" ]; then if [ "`cd $S_FP_0;pwd`" == "`cd $S_FP_1;pwd`" ]; then SB_ASSERTION_FAILED="t" S_GUID_CMP="37d42234-a57e-4d78-b52c-f1e0305090e7" fi else if [ "$S_COMPARISON_MODE" == "cmode_str0_str1" ]; then if [ "$S_FP_0_STR" == "$S_FP_1_STR" ]; then SB_ASSERTION_FAILED="t" S_GUID_CMP="b0eb5d1d-9b86-4d66-812c-f1e0305090e7" fi # The if [ "$S_FP_0" == "$S_FP_1" ] ... # has already been tried at the very start # of the huge if-block. else echo "" echo "This script is flawed." echo "" echo " S_FP_0=$S_FP_0" echo " S_FP_1=$S_FP_1" echo " S_GUID_CRAWL=$S_GUID_CRAWL" echo " S_GUID_CMP=$S_GUID_CMP" echo " S_COMPARISON_MODE=$S_COMPARISON_MODE" echo "" echo "GUID=='14286012-4658-42f9-94cb-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 # exit with error fi fi fi fi fi #-------- SB_FUNC_MMMV_ASSERT_FILE_PATHS_DIFFER_T1_ASSERTION_FAILED="$SB_ASSERTION_FAILED" # global if [ "$SB_ASSERTION_FAILED" == "t" ]; then if [ "$SB_DO_NOT_TRHOW_ON_ASSERTION_FAILURE" != "t" ]; then echo "" echo "The file paths " echo "" echo " S_FP_0=$S_FP_0" echo "" echo " S_FP_1=$S_FP_1" echo "" echo "are required to differ and " echo "they are required to differ also after normalization." echo "" echo "GUID=='3f8afd21-08d6-487f-b3cb-f1e0305090e7'" echo "GUID=='$S_GUID_CMP'" # comparison echo "GUID=='$S_GUID_CRAWL'" # tree crawling at the schematic if [ "$S_GUID" != "" ]; then echo "GUID=='$S_GUID'" # GUID as an input parameter fi echo "" #---- cd $S_FP_ORIG exit 1 # exit with error fi fi } # func_mmmv_assert_file_paths_differ_t1 #-------------------------------------------------------------------------- # Activity aliases for comfort. if [ "$S_ACTIVITY_OF_THIS_SCRIPT" == "up" ]; then S_ACTIVITY_OF_THIS_SCRIPT="overwrite_remote_with_local" ................................................................................ S_ACTIVITY_OF_THIS_SCRIPT="help" fi if [ "$S_ACTIVITY_OF_THIS_SCRIPT" == "-help" ]; then S_ACTIVITY_OF_THIS_SCRIPT="help" fi #-------- if [ "$S_ACTIVITY_OF_THIS_SCRIPT" == "rm" ]; then S_ACTIVITY_OF_THIS_SCRIPT="delete_local_copy" fi if [ "$S_ACTIVITY_OF_THIS_SCRIPT" == "del" ]; then S_ACTIVITY_OF_THIS_SCRIPT="delete_local_copy" fi if [ "$S_ACTIVITY_OF_THIS_SCRIPT" == "delete" ]; then S_ACTIVITY_OF_THIS_SCRIPT="delete_local_copy" fi #-------- if [ "$S_ACTIVITY_OF_THIS_SCRIPT" == "info" ]; then S_ACTIVITY_OF_THIS_SCRIPT="about" fi if [ "$S_ACTIVITY_OF_THIS_SCRIPT" == "--info" ]; then S_ACTIVITY_OF_THIS_SCRIPT="about" ................................................................................ if [ "$2" != "" ]; then if [ "$2" == "use_autogenerated_commit_message" ]; then if [ "$3" != "" ]; then echo "" echo "If the first console argument is \"overwrite_local_with_remote\" and" echo "the second console argument is \"use_autogenerated_commit_message\", " echo "then there should not be a 3. console argument." echo "GUID=='468fa904-55da-4388-81cb-f1e0305090e7'" S_ACTIVITY_OF_THIS_SCRIPT="help" SB_EXIT_WITH_ERROR="t" fi else if [ "$2" == "read_commit_message_from_file" ]; then S_FP_MESSAGE_FILE_CANDIDATE="$3" # file path candidate if [ "$S_FP_MESSAGE_FILE_CANDIDATE" == "" ]; then ................................................................................ echo "" echo "If the first console argument is " echo "\"overwrite_local_with_remote\" and" echo "the second console argument is " echo "\"read_commit_message_from_file\", " echo "then there should be also a 3. console argument " echo "that is expected to be a file path to a text file." echo "GUID=='559c7db3-15af-4a7d-bdbb-f1e0305090e7'" S_ACTIVITY_OF_THIS_SCRIPT="help" SB_EXIT_WITH_ERROR="t" fi if [ "$SB_EXIT_WITH_ERROR" == "f" ]; then if [ "$4" != "" ]; then echo "" echo "If the first console argument is " ................................................................................ echo "the second console argument is " echo "\"read_commit_message_from_file\", " echo "then there should be exactly 3. console arguments, " echo "not 4 or more. Unfortunately the 4. argument is currently " echo "---citation--start---" echo "$4" echo "---citation--end-----" echo "GUID=='5e662e45-13a1-499b-9dbb-f1e0305090e7'" S_ACTIVITY_OF_THIS_SCRIPT="help" SB_EXIT_WITH_ERROR="t" fi fi if [ "$SB_EXIT_WITH_ERROR" == "f" ]; then if [ ! -e "$S_FP_MESSAGE_FILE_CANDIDATE" ]; then echo "" echo "The commit message file path candidate " echo "references either a missing file or " echo "a broken symlink." echo "GUID=='15f6e772-31ba-4f5e-97bb-f1e0305090e7'" S_ACTIVITY_OF_THIS_SCRIPT="help" SB_EXIT_WITH_ERROR="t" fi fi if [ "$SB_EXIT_WITH_ERROR" == "f" ]; then if [ -d "$S_FP_MESSAGE_FILE_CANDIDATE" ]; then echo "" echo "The commit message file path candidate " echo "references a folder, but it should " echo "reference a text file." echo "GUID=='3225928c-0920-4018-95bb-f1e0305090e7'" S_ACTIVITY_OF_THIS_SCRIPT="help" SB_EXIT_WITH_ERROR="t" fi fi if [ "$SB_EXIT_WITH_ERROR" == "f" ]; then S_TMP_0="`filesize $S_FP_MESSAGE_FILE_CANDIDATE`" S_TMP_1="`ruby -e \"s_out='OK'; if (2000<$S_TMP_0) then s_out='too_big' end; print(s_out);\"`" if [ "$S_TMP_1" == "too_big" ]; then echo "" echo "The commit message file path " echo "references a file that has a size of $S_TMP_0 bytes." echo "The suspicion is that it is a wrong file. " echo "because a commit message is usually not that lengthy." echo "GUID=='21090045-08fe-4487-81bb-f1e0305090e7'" S_ACTIVITY_OF_THIS_SCRIPT="help" SB_EXIT_WITH_ERROR="t" else if [ "$S_TMP_0" == "0" ]; then echo "" echo "The commit message file path " echo "references a file that has a size of 0 (zero) bytes." ................................................................................ echo "" echo " \"use_autogenerated_commit_message\"" echo "" echo "in stead of the option " echo "" echo " \"read_commit_message_from_file\" ." echo "" echo "GUID=='a539fb61-243d-4e0c-82bb-f1e0305090e7'" S_ACTIVITY_OF_THIS_SCRIPT="help" SB_EXIT_WITH_ERROR="t" fi fi fi if [ "$SB_EXIT_WITH_ERROR" == "f" ]; then S_TMP_0="`file --mime-type $S_FP_MESSAGE_FILE_CANDIDATE | grep text `" ................................................................................ echo "The commit message file path " echo "references a file that has a MIME type of " echo "" echo "`file --mime-type $S_FP_MESSAGE_FILE_CANDIDATE`" echo "" echo "The commit message file must be a text file and " echo "text files have the string \"text\" in their MIME type name." echo "GUID=='0e00aa42-a7dd-4e63-b2ab-f1e0305090e7'" S_ACTIVITY_OF_THIS_SCRIPT="help" SB_EXIT_WITH_ERROR="t" fi fi fi # read_commit_message_from_file fi fi else if [ "$S_ACTIVITY_OF_THIS_SCRIPT" == "delete_local_copy" ]; then if [ "$2" != "" ]; then # the 2. arg is optional here if [ "$2" != "$S_ARGNAME_ACTIVITY_SHRED_ARG_2" ]; then echo "" echo "If the first console argument is \"delete_local_copy\", then" echo "the second console argument is allowed to be only " echo "" echo " \"$S_ARGNAME_ACTIVITY_SHRED_ARG_2\", without quotation marks." echo "GUID=='53d97712-0caf-4847-b5ab-f1e0305090e7'" S_ACTIVITY_OF_THIS_SCRIPT="help" SB_EXIT_WITH_ERROR="t" fi fi else if [ "$S_ACTIVITY_OF_THIS_SCRIPT" != "print_script_version" ]; then if [ "$S_ACTIVITY_OF_THIS_SCRIPT" != "help" ]; then echo "" echo "The very first console argument " echo "of this script is expected to be " echo "a command that is specific to this script." echo "GUID=='5d8d1e92-ac26-408a-81ab-f1e0305090e7'" S_ACTIVITY_OF_THIS_SCRIPT="help" SB_EXIT_WITH_ERROR="t" fi fi fi fi fi ................................................................................ echo " clone_all <remote repository url>" echo " clone_public <remote repository url>" echo " overwrite_local_with_remote" echo "" echo " overwrite_remote_with_local (use_autogenerated_commit_message)?" echo " overwrite_remote_with_local read_commit_message_from_file <path to a text file>" echo "" echo " delete_local_copy ($S_ARGNAME_ACTIVITY_SHRED_ARG_2)?" echo " help" echo " print_script_version" echo " exit # just for testing" echo "" #---- cd $S_FP_ORIG if [ "$SB_EXIT_WITH_ERROR" == "t" ]; then ................................................................................ # To allow the version to be used as sub-part of file names and # folder names, the version must not contain any spaces, line breaks # and other characters that have a special meaning in Bash. # # If the version ID did not match the GUID regex, then I would have to # write a long comment about it not being allowed to match the # GUID regex. :-D S_VERSION_OF_THIS_SCRIPT="23dc37cc-4d31-4444-a52c-f1e0305090e7" if [ "$S_ACTIVITY_OF_THIS_SCRIPT" == "print_script_version" ]; then echo "The version of this script is: $S_VERSION_OF_THIS_SCRIPT" #---- cd $S_FP_ORIG exit 0 fi ................................................................................ fi fi #---- if [ "$SB_THROW" == "t" ]; then echo "" echo "This Bash script is flawed. " echo "fun_assertion_t1() assertion failed." echo "GUID=='c2afa84b-ad9b-41b4-a4ab-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 fi } # fun_assertion_t1 ................................................................................ echo "The directory " echo "`pwd`" echo "does not contain a Fossil repository file named " echo "" echo " $S_FP_FOSSILFILE_NAME" echo "" echo "Aborting script." echo "GUID=='b6307f42-cfba-4f42-b4ab-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 fi fun_sandbox_folder_or_symlink_exists if [ "$SB_SANDBOX_DIR_EXISTS" == "f" ]; then ................................................................................ echo "The directory " echo "`pwd`" echo "does not contain a directory named " echo "" echo " $S_FP_SANDBOX_DIRECTORY_NAME" echo "" echo "Aborting script." echo "GUID=='2619a005-53ea-46b9-a79b-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 fi } # fun_assert_repository_local_copy_existence ................................................................................ echo "`pwd`" echo "already contain a file named " echo "" echo " $S_FP_FOSSILFILE_NAME" echo "" echo "To avoid overwriting an existing local copy, this script is aborted" echo "and nothing is downloaded/uploaded by this script." echo "GUID=='3cdf8c33-e911-4ecf-819b-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 fi if [ "$SB_SANDBOX_DIR_EXISTS" == "t" ]; then echo "" ................................................................................ echo "`pwd`" echo "already contains a directory named " echo "" echo " $S_FP_SANDBOX_DIRECTORY_NAME" echo "" echo "To avoid overwriting an existing local copy, this script is aborted" echo "and nothing is downloaded/uploaded by this script." echo "GUID=='e054e73b-52b7-4999-929b-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 fi } # fun_assert_the_lack_of_repository_local_copy_t1 ................................................................................ #-------------------------------------------------------------------------- fun_last_minute_checks_t1() { # Last minute checks, just to be sure. local S_FP_FORBIDDEN_VALUE=$1 if [ "$S_FP_FORBIDDEN_VALUE" == "/" ]; then echo "" echo "This Bash script is flawed." echo "GUID=='3c4e5af3-7901-474c-939b-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 fi if [ "$S_FP_FORBIDDEN_VALUE" == "$HOME" ]; then echo "" echo "This Bash script is flawed." echo "GUID=='c200ef46-b3f7-4204-919b-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 fi if [ "$S_FP_FORBIDDEN_VALUE" == "/home" ]; then echo "" echo "This Bash script is flawed." echo "GUID=='d2a65b5e-0591-4332-948b-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 fi if [ "$S_FP_FORBIDDEN_VALUE" == "/root" ]; then echo "" echo "This Bash script is flawed." echo "GUID=='03b089fe-baa7-4a68-b38b-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 fi if [ "$S_FP_FORBIDDEN_VALUE" == "/etc" ]; then echo "" echo "This Bash script is flawed." echo "GUID=='0062ae2c-e3a2-4764-b28b-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 fi if [ "$S_FP_FORBIDDEN_VALUE" == "/usr" ]; then echo "" echo "This Bash script is flawed." echo "GUID=='9de55d34-dbca-4803-918b-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 fi } # fun_last_minute_checks_t1 ................................................................................ fun_folder_is_empty_t1 "$S_FP_DIR" fun_assertion_t1 "$SB_FOLDER_IS_EMPTY" if [ "$SB_FOLDER_IS_EMPTY" == "t" ]; then echo "" echo "This Bash script is flawed. The " echo "$S_FP_DIR" echo "can not possibly be empty, because it contains " echo "at least one file, which is " echo "this very same Bash script that outputs the current error message." echo "GUID=='fb573a47-7195-4c06-b18b-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 fi #-------------------------------------------------------------------------- ................................................................................ SB_SANDBOX_CONTENT_MIGHT_HAVE_BEEN_CHANGED="t" fun_last_minute_checks_t1 "`pwd`" if [ "$S_FP_SANDBOX" == "`pwd`" ]; then rm -fr ./* else echo "" echo "This Bash script is flawed." echo "GUID=='20848e2d-db76-40f0-b18b-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 fi fi mv -f $S_TMP_FOR_LOCAL/* $S_FP_SANDBOX/ # the -f is for empty source ................................................................................ rm -fr $S_TMP_FOR_LOCAL #---- fun_folder_is_empty_t1 "$S_FP_SANDBOX" if [ "$SB_FOLDER_IS_EMPTY" == "f" ]; then if [ "$S_FP_SANDBOX" != "`pwd`" ]; then echo "" echo "This Bash script is flawed." echo "GUID=='74c20b5b-81c4-4dea-a17b-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 fi find . -name '*' | xargs fossil add --force --dotfiles --case-sensitive TRUE SB_SANDBOX_CONTENT_MIGHT_HAVE_BEEN_CHANGED="t" ................................................................................ echo "The file or symlink to it was fine at " echo "the start of this script, it passed the various tests, " echo "but for some reason it got deleted or its target . " echo "got deleted. If the commit message file or" echo "the symlink target resided within the sandbox, then " echo "a recommendation is to use a file that resides " echo "outside of the sandbox." echo "GUID=='489d0043-ac2a-46ae-857b-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 fi if [ -d "$S_FP_MESSAGE_FILE_CANDIDATE" ]; then # folder or a symlink to a folder echo "" echo "The commit message file path does not reference " echo "a file. It references a folder or a symlink to a folder." echo "The file or symlink to it was fine at " echo "the start of this script, it passed the various tests, " echo "but for some reason there were changes. " echo "GUID=='1c1054d1-d44f-4830-a47b-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 fi cat $S_FP_MESSAGE_FILE_CANDIDATE > $S_TMP_FOR_COMMIT_MESSAGE # else ................................................................................ #---- cd $S_FP_ORIG exit 0 fi # overwrite_remote_with_local #-------------------------------------------------------------------------- if [ "$S_ACTIVITY_OF_THIS_SCRIPT" == "delete_local_copy" ]; then #-------- SB_THERE_IS_SOMETHING_TO_DELETE="f" if [ "$SB_FOSSILFILE_EXISTS" == "t" ]; then SB_THERE_IS_SOMETHING_TO_DELETE="t" fi if [ "$SB_SANDBOX_DIR_EXISTS" == "t" ]; then SB_THERE_IS_SOMETHING_TO_DELETE="t" ................................................................................ # Includes the $2=="" case # id est if the control flow is in here, then there # is a need to prompt for confirmation. # The skipping of the prompt is necessary for # software that use this script as its sub-component. #-------- echo "" echo "The command \"delete_local_copy\" deletes " echo "the repository file, the sandbox and " echo "the associated automatically created archives." echo "" read -p "Proceed with deletion? (Yes/whatever_else) " S_TMP_0 S_TMP_1="`echo $S_TMP_0 | gawk '{print tolower($1)}'`" if [ "$S_TMP_1" == "yes" ]; then echo "" ................................................................................ printf "Deleting ... " else fun_exit_without_any_errors_t1 fi fi fi #-------- cd $S_FP_ORIG # to make sure that we're not in the sandbox directory and # to make sure that we're not in the archive directory #---- # The next 3 checks can bee seen to form a complete graph, # in this case a triangle, with corner points # S_FP_SANDBOX, S_FP_ARCHIVES, S_FP_FOSSILFILE connected # with lines of type "!=". S_GUID="470c7051-b162-4cba-b51c-f1e0305090e7" func_mmmv_assert_file_paths_differ_t1 "$S_FP_FOSSILFILE" "$S_FP_SANDBOX" "$S_GUID" S_GUID="45b8df6a-0c67-4d1e-a71c-f1e0305090e7" func_mmmv_assert_file_paths_differ_t1 "$S_FP_SANDBOX" "$S_FP_ARCHIVES" "$S_GUID" S_GUID="42226761-7b9d-4cfb-bc1c-f1e0305090e7" func_mmmv_assert_file_paths_differ_t1 "$S_FP_ARCHIVES" "$S_FP_FOSSILFILE" "$S_GUID" #---- # The next 3 checks turn the triangle to a tetrahedron, where # the S_FP_ORIG is the "top of the pyramid". S_GUID="a9379a5b-d3aa-419b-820c-f1e0305090e7" func_mmmv_assert_file_paths_differ_t1 "$S_FP_ORIG" "$S_FP_FOSSILFILE" "$S_GUID" S_GUID="6d2d0251-9d35-4747-940c-f1e0305090e7" func_mmmv_assert_file_paths_differ_t1 "$S_FP_ORIG" "$S_FP_ARCHIVES" "$S_GUID" S_GUID="3b972413-c33d-4867-910c-f1e0305090e7" func_mmmv_assert_file_paths_differ_t1 "$S_FP_ORIG" "$S_FP_SANDBOX" "$S_GUID" #-------- cd $S_FP_ORIG # just in case SB_OK_TO_USE_RM_IN_STEAD_OF_SHRED="t" # shred is still used, if available if [ "$SB_FOSSILFILE_EXISTS" == "t" ]; then fun_last_minute_checks_t1 "`pwd`" func_mmmv_shred_t1 "$S_FP_FOSSILFILE" "$SB_OK_TO_USE_RM_IN_STEAD_OF_SHRED" fi if [ "$SB_SANDBOX_DIR_EXISTS" == "t" ]; then fun_last_minute_checks_t1 "`pwd`" func_mmmv_shred_t1 "$S_FP_SANDBOX" "$SB_OK_TO_USE_RM_IN_STEAD_OF_SHRED" fi if [ "$SB_ARCHIVE_DIR_EXISTS" == "t" ]; then fun_last_minute_checks_t1 "`pwd`" func_mmmv_shred_t1 "$S_FP_ARCHIVES" "$SB_OK_TO_USE_RM_IN_STEAD_OF_SHRED" fi #-------- if [ "$SB_THERE_IS_SOMETHING_TO_DELETE" == "t" ]; then if [ "$2" != "$S_ARGNAME_ACTIVITY_SHRED_ARG_2" ]; then echo "✓" echo "" fi fi #-------- cd $S_FP_ORIG exit 0 fi # delete_local_copy #-------------------------------------------------------------------------- # All possible actions must have been described # above this code block. echo "" echo "This Bash script is flawed." echo "GUID=='1b3f0b52-848d-494a-a47b-f1e0305090e7'" echo "" #---- cd $S_FP_ORIG exit 1 #========================================================================== |