diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..fec41d9 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,18 @@ +name: CI + +on: + pull_request: {} + push: + branches: [ master ] + +jobs: + shellcheck: + name: ShellCheck + runs-on: ubuntu-latest + timeout-minutes: 5 + + steps: + - uses: actions/checkout@v4 + - uses: ludeeus/action-shellcheck@2.0.0 + with: + severity: warning diff --git a/c_template.sh b/c_template.sh index 64b142b..1ab1f9a 100755 --- a/c_template.sh +++ b/c_template.sh @@ -7,15 +7,17 @@ fi filename="$1" -str="#include -\n#include -\n\nint main() -\n{ - \n\tint aux;\n - \n\tscanf(\"%d\", &aux);\n - \n\tprintf(\"%d\", aux);\n - \n\treturn 0; -\n}" +cat << EOF > "$filename.c" +#include +#include -echo -e $str > "$filename.c" -echo "Done!" \ No newline at end of file +int main() +{ +\tint aux; +\tscanf("%d", &aux); +\tprintf("%d", aux); +\treturn 0; +} +EOF + +echo "Done!" diff --git a/cpp_competitive_template.sh b/cpp_competitive_template.sh index eac99bf..7d34899 100755 --- a/cpp_competitive_template.sh +++ b/cpp_competitive_template.sh @@ -14,14 +14,17 @@ main() { while getopts "c:s:h" flag; do case $flag in c) - num_problems=$OPTARG - contest_flag=1 ;; + num_problems=$OPTARG + contest_flag=1 ;; s) - problem_names=$OPTARG - specify_flag=1 ;; + problem_names=$OPTARG + specify_flag=1 ;; h) - print_usage - exit ;; + print_usage + exit ;; + *) + print_usage + exit 1 ;; esac done @@ -32,27 +35,27 @@ main() { exit 1 fi - if (($contest_flag > 0)); then + if ((contest_flag > 0)); then echo "creating contest problems..." problems=("A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S" "T") - for ((i=0;i<$num_problems;i++)); + for ((i=0;i 0)) ;then + elif ((specify_flag > 0)) ;then - names=$(echo $problem_names | tr "," " ") + names=$(echo "$problem_names" | tr "," " ") for name in $names do echo "creating file $name.cpp..." - create_file $name + create_file "$name" done else filename="$1" echo "creating file $filename.cpp..." - create_file $filename + create_file "$filename" fi create_io_files @@ -60,22 +63,25 @@ main() { } create_file() { - local code="#include - \nusing namespace std; - \n#define DEBUG(x) cout << #x << \" >>>> \" << x << endl - \n#define MID(l, r) (l + (r - l) / 2) - \n#define CEILDIVISION(x, y) ((x + y - 1) / y) - \n#define INF (int)1e9 - \n#define LONGINF (long long)1e18 - \n#define MEM(arr, val) memset(arr, (val), sizeof(arr)) - \n#define FASTIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); - \nconst int MOD = 1000000007; // 10^9 - 7 - \n - \nint main() { - \n\tFASTIO;\n\t\n\t\n\treturn 0; - \n}" + cat << EOF > "$1.cpp" +#include +using namespace std; +#define DEBUG(x) cout << #x << " >>>> " << x << endl +#define MID(l, r) (l + (r - l) / 2) +#define CEILDIVISION(x, y) ((x + y - 1) / y) +#define INF (int)1e9 +#define LONGINF (long long)1e18 +#define MEM(arr, val) memset(arr, (val), sizeof(arr)) +#define FASTIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); +const int MOD = 1000000007; // 10^9 - 7 + +int main() { +\tFASTIO; - echo -e $code > "$1.cpp" + +\treturn 0; +} +EOF } create_io_files() { diff --git a/create_bootable_usbstick.sh b/create_bootable_usbstick.sh index e79d4a7..aead588 100755 --- a/create_bootable_usbstick.sh +++ b/create_bootable_usbstick.sh @@ -8,17 +8,17 @@ if (($# != 2)); then fi -read -p $'\nEnter the Operating System: For Windows type: windows | For Linux type: linux \n' os +read -rp $'\nEnter the Operating System: For Windows type: windows | For Linux type: linux \n' os if [ "$os" = "linux" ]; then deviceToUmount="${1}1" - sudo umount $deviceToUmount + sudo umount "$deviceToUmount" echo "Unmounting device..." - sudo dd bs=4M if=$2 of=$1 status=progress oflag=sync + sudo dd bs=4M if="$2" of="$1" status=progress oflag=sync echo "Done!" @@ -37,11 +37,11 @@ elif [ "$os" = "windows" ]; then deviceToUmount="${1}1" - sudo umount $deviceToUmount + sudo umount "$deviceToUmount" echo "Unmounting device..." - sudo woeusb -v --target-filesystem NTFS --device $2 $1 + sudo woeusb -v --target-filesystem NTFS --device "$2" "$1" echo $'This script requires woeusb to be installed, install it using the following PPA:\nsudo add-apt-repository ppa:nilarimogard/webupd8\nsudo apt update\nsudo apt install woeusb' diff --git a/pdf2csv.sh b/pdf2csv.sh index 8c6f45f..2e036fe 100755 --- a/pdf2csv.sh +++ b/pdf2csv.sh @@ -7,7 +7,7 @@ fi echo "Converting pdf to txt..." -pdftotext -layout $1 $2.txt +pdftotext -layout "$1" "$2.txt" # After convert it to txt we have to parse through the lines and separate the fields by commas @@ -15,9 +15,9 @@ echo "Converting txt to csv..." # Let's add an space after the first field, replace the commas with dots and then separate them -awk '{ sub(/^[ \t]+/, ""); print}' $2.txt | sed 's/ / /' | awk '{gsub(/,/,".")} 1' | -awk -F'[[:space:]][[:space:]]+' 'BEGIN{OFS=",";} {print $1, $2, $3, $4, $5, $6, $7}' > $2.csv +awk '{ sub(/^[ \t]+/, ""); print}' "$2.txt" | sed 's/ / /' | awk '{gsub(/,/,".")} 1' | +awk -F'[[:space:]][[:space:]]+' 'BEGIN{OFS=",";} {print $1, $2, $3, $4, $5, $6, $7}' > "$2.csv" -rm $2.txt +rm "$2.txt" echo "Done!" diff --git a/run_script.sh b/run_script.sh index f292e5a..e75028a 100755 --- a/run_script.sh +++ b/run_script.sh @@ -8,23 +8,23 @@ main() { fi # get flags - contest_flag=0 - specify_flag=0 - num_problems=0 while getopts "h" flag; do case $flag in h) - print_usage - exit ;; + print_usage + exit ;; + *) + print_usage + exit 1 ;; esac done filename="$1" - run_file $filename + run_file "$filename" } run_file() { - g++ $1 && ./a.out -fmax-errors=1 out.txt + g++ "$1" && ./a.out -fmax-errors=1 out.txt } print_usage() {