Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Operator apply_diffs.sh #63

Open
marcosxaviergil opened this issue Nov 12, 2024 · 1 comment
Open

Operator apply_diffs.sh #63

marcosxaviergil opened this issue Nov 12, 2024 · 1 comment
Labels
question Further information is requested

Comments

@marcosxaviergil
Copy link

Using Ubuntu Budgie

The error you are encountering is due to incorrect syntax in the script. It seems that the script is trying to compare strings using the == operator, which is not supported by the sh shell. Instead, you should use the = operator to compare strings.

Here is the corrected script:

#!/bin/bash

set -e

DIFFS_DIR="ldap-overleaf-sl/sharelatex_diff"
ORI_DIR="ldap-overleaf-sl/sharelatex_ori"
PATCHED_DIR="ldap-overleaf-sl/sharelatex"

for diff_file in "$DIFFS_DIR"/*.diff; do
filename=$(basename "$diff_file" ".diff")
if [ "$filename" = ".gitkeep" ]; then
continue
fi

original_file="$ORI_DIR/$filename"
patched_file="$PATCHED_DIR/$filename"

if [ -f "$original_file" ]; then
    cp "$original_file" "$patched_file"
    patch "$patched_file" "$diff_file"
else
    echo "No original file for $filename in $ORI_DIR."
fi

done
Explanation of Corrections:
Comparison Operator:

Replaced == with = in the line if [ "$filename" = ".gitkeep" ]; then.
Shebang:

Ensure the script uses #!/bin/bash to guarantee it is interpreted by Bash, which supports array syntax and other advanced shell features.
How to Run the Script:
To run the script, use the bash command instead of sh:

sudo bash scripts/apply_diffs.sh
This ensures that the script is interpreted by Bash, which supports array syntax and other advanced shell features.

Verification of Patches:
To verify if the patches were applied correctly, you can compare the original files with the patched files. For example, you can use the diff command to compare the files:

diff "$ORI_DIR/$filename" "$PATCHED_DIR/$filename"
If the patches were applied correctly, you should see the differences between the original files and the patched files.

@yzx9
Copy link
Collaborator

yzx9 commented Nov 15, 2024

Could you please format your issue to make it easier to read?

@yzx9 yzx9 added the question Further information is requested label Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants