diff --git a/bin/compile-manuscript.sh b/bin/compile-manuscript.sh index d9264b3..ebd2054 100755 --- a/bin/compile-manuscript.sh +++ b/bin/compile-manuscript.sh @@ -53,7 +53,6 @@ while [[ $# -gt 0 ]]; do ;; esac done -remainingArgs=${POSITIONAL_ARGS[@]} set -- "${POSITIONAL_ARGS[@]}" # restore positional parameters # If this is a git repo and no name has been provided, name the draft after the current branch @@ -63,9 +62,9 @@ fi # Check if this directory already exists outDir="$outDir/${draftName}" -if [ -d $outDir ]; then +if [ -d "$outDir" ]; then echo "The folder $outDir already exists." - read -p "Enter YES to overwrite, or Ctrl-C to cancel: " confirm && [ $confirm = "YES" ] || exit 1 + read -rp "Enter YES to overwrite, or Ctrl-C to cancel: " confirm && [ "$confirm" = "YES" ] || exit 1 fi draftFile="$outDir/${draftName}" @@ -73,20 +72,20 @@ draftFile="$outDir/${draftName}" echo "Compiling draft \"${draftName}\"..." # Create the draft directory if it doesn't already exist -mkdir -p $outDir +mkdir -p "$outDir" # Initialize merged file -echo > $draftFile.md +echo > "$draftFile".md # Grab content files and add a page break to the end of each one. # Obsidian specifically creates "folder notes," which are named for the directory, so we make sure to exclude it. -find "$inDir" -type f -wholename "* *.md" ! -name content.md -print0 | sort -z | while read -d $'\0' file +find "$inDir" -type f -wholename "* *.md" ! -name content.md -print0 | sort -z | while read -rd $'\0' file do # Add newline to Markdown doc - echo >> $draftFile.md + echo >> "$draftFile".md # Clean up incoming Markdown and append it to final doc - sed "s|(../|($inDir/../|g" "$file" >> $draftFile.md - echo "\\newpage" >> $draftFile.md + sed "s|(../|($inDir/../|g" "$file" >> "$draftFile".md + echo "\\newpage" >> "$draftFile".md done # Generate the output files: @@ -94,9 +93,9 @@ done # Markdown -> EPUB # Markdown -> PDF (A4 size) # Markdown -> PDF (B6/Standard book size) -pandoc -t docx $draftFile.md -o $draftFile.docx --metadata-file "$metadataFile" -pandoc -t epub $draftFile.md -o $draftFile.epub --metadata-file "$metadataFile" -pandoc $draftFile.md -o ${draftFile}-a4.pdf --metadata-file "$metadataFile" -V geometry:"a4paper" -V fontsize:"12pt" -pandoc $draftFile.md -o ${draftFile}-b6.pdf --metadata-file "$metadataFile" -V geometry:"b6paper" -V fontsize:"10pt" +pandoc -t docx "$draftFile".md -o "$draftFile".docx --metadata-file "$metadataFile" +pandoc -t epub "$draftFile".md -o "$draftFile".epub --metadata-file "$metadataFile" +pandoc "$draftFile".md -o "$draftFile"-a4.pdf --metadata-file "$metadataFile" -V geometry:"a4paper" -V fontsize:"12pt" +pandoc "$draftFile".md -o "$draftFile"-b6.pdf --metadata-file "$metadataFile" -V geometry:"b6paper" -V fontsize:"10pt" echo "Done! Your new draft is in $outDir" diff --git a/bin/format-drives.sh b/bin/format-drives.sh index 332f536..b4ff27a 100755 --- a/bin/format-drives.sh +++ b/bin/format-drives.sh @@ -46,7 +46,6 @@ while [[ $# -gt 0 ]]; do ;; --help|-h) usage - shift ;; *) POSITIONAL_ARGS+=("$1") # save positional arg @@ -57,8 +56,8 @@ done set -- "${POSITIONAL_ARGS[@]}" # restore positional parameters -cryptsetup luksOpen $luks_partition nixos-crypt -mkfs.btrfs -L nixos $root_partition +cryptsetup luksOpen "$luks_partition" nixos-crypt +mkfs.btrfs -L nixos "$root_partition" mount /dev/mapper/nixos-crypt /mnt btrfs subvolume create /mnt/@ btrfs subvolume create /mnt/@home @@ -67,13 +66,13 @@ btrfs subvolume create /mnt/@nix btrfs subvolume create /mnt/@swap umount /mnt -mount -o subvol=@ $root_partition /mnt +mount -o subvol=@ "$root_partition" /mnt mkdir -p /mnt/{boot,home,var/log,nix,swap} -mount $boot_partition /mnt/boot -mount -o subvol=@home $root_partition /mnt/home -mount -o subvol=@log $root_partition /mnt/var/log -mount -o subvol=@nix $root_partition /mnt/nix -mount -o subvol=@swap $root_partition /mnt/swap +mount "$boot_partition" /mnt/boot +mount -o subvol=@home "$root_partition" /mnt/home +mount -o subvol=@log "$root_partition" /mnt/var/log +mount -o subvol=@nix "$root_partition" /mnt/nix +mount -o subvol=@swap "$root_partition" /mnt/swap echo "Disks partitioned and mounted to /mnt." # Generate hardware-configuration.nix diff --git a/bin/nixos-operations-script.sh b/bin/nixos-operations-script.sh index b5cb669..b14ef6c 100755 --- a/bin/nixos-operations-script.sh +++ b/bin/nixos-operations-script.sh @@ -73,7 +73,7 @@ while [[ $# -gt 0 ]]; do ;; esac done -remainingArgs=${POSITIONAL_ARGS[@]} +remainingArgs=${POSITIONAL_ARGS[*]} set -- "${POSITIONAL_ARGS[@]}" # restore positional parameters if [ -z "${flakeDir}" ]; then @@ -81,28 +81,28 @@ if [ -z "${flakeDir}" ]; then exit 1 fi -cd $flakeDir +cd "$flakeDir" || exit 1 echo "Pulling the latest version of the repository..." -/run/wrappers/bin/sudo -u $user /run/current-system/sw/bin/git pull +/run/wrappers/bin/sudo -u "$user" /run/current-system/sw/bin/git pull if [ $update = true ]; then echo "Updating flake.lock..." - /run/wrappers/bin/sudo -u $user /run/current-system/sw/bin/nix flake update --commit-lock-file - /run/wrappers/bin/sudo -u $user git push + /run/wrappers/bin/sudo -u "$user" /run/current-system/sw/bin/nix flake update --commit-lock-file + /run/wrappers/bin/sudo -u "$user" git push else echo "Skipping 'nix flake update'..." fi options="--flake ${flakeDir}#${hostname} ${remainingArgs} --use-remote-sudo --log-format multiline-with-logs" -if [[ -n "${buildHost}" && $operation != "build" && $operation != *"dry"* ]]; then +if [[ -n "${buildHost}" && "$operation" != "build" && "$operation" != *"dry"* ]]; then echo "Remote build detected, running this operation first: nixos-rebuild build ${options} --build-host $buildHost" - /run/current-system/sw/bin/nixos-rebuild build $options --build-host $buildHost + /run/current-system/sw/bin/nixos-rebuild build "$options" --build-host "$buildHost" echo "Remote build complete!" fi echo "Running this operation: nixos-rebuild ${operation} ${options}" -/run/current-system/sw/bin/nixos-rebuild $operation $options +/run/current-system/sw/bin/nixos-rebuild "$operation" "$options" exit 0