Skip to content

Commit

Permalink
fix script formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Tofel committed Jan 9, 2024
1 parent d929bed commit fd568f8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/client-compatibility-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:
- name: Gather TOML config files
run: |
set -x
./.github/scripts/copy_toml.sh "default ocr" ./integration-tests ./toml_configs
./.github/scripts/copy_toml.sh 'default ocr' ./integration-tests ./toml_configs
cd ./toml_configs && zip toml_configs.zip ./
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v3
Expand Down
58 changes: 29 additions & 29 deletions copy_toml.sh
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
#!/bin/bash
# This script searches for TOML files matching given regex patterns and copies them to a target directory.
# This script searches for TOML files matching given regex patterns and copies them to a target directory.

echo "patterns: $1"
echo "search_folder: $2"
echo "target_folder: $3"
echo "patterns: $1"
echo "search_folder: $2"
echo "target_folder: $3"

if [ "$#" -ne 3 ]; then
echo "Usage: $0 <pattern-array> <search-folder> <target-folder>"
exit 1
fi
if [ "$#" -ne 3 ]; then
echo "Usage: $0 <pattern-array> <search-folder> <target-folder>"
exit 1
fi

declare -a patterns=($1) # Array of regex filename patterns
search_folder=$2 # Folder to search in
target_folder=$3 # Target folder for copying files
declare -a patterns=($1) # Array of regex filename patterns
search_folder=$2 # Folder to search in
target_folder=$3 # Target folder for copying files

if [ ! -d "$search_folder" ]; then
echo "Search folder does not exist: $search_folder"
exit 1
fiwhy
if [ ! -d "$search_folder" ]; then
echo "Search folder does not exist: $search_folder"
exit 1
fiwhy

mkdir -p "$target_folder"
mkdir -p "$target_folder"

copy_files() {
local pattern=$1
# Find .toml files, extract filenames, and match pattern
find "$search_folder" -type f -name "*.toml" | while read -r file; do
filename=$(basename "$file")
if [[ $filename =~ $pattern ]]; then
cp "$file" "$target_folder"
fi
done
}
copy_files() {
local pattern=$1
# Find .toml files, extract filenames, and match pattern
find "$search_folder" -type f -name "*.toml" | while read -r file; do
filename=$(basename "$file")
if [[ $filename =~ $pattern ]]; then
cp "$file" "$target_folder"
fi
done
}

for pattern in "${patterns[@]}"; do
copy_files "$pattern"
done
for pattern in "${patterns[@]}"; do
copy_files "$pattern"
done

0 comments on commit fd568f8

Please sign in to comment.