Skip to content

Fix MacOS tools alias error #426

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

Merged
merged 2 commits into from
May 12, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions opensaas-sh/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,6 @@ If you're running the `patch.sh` or `diff.sh` scripts on Mac, you need to instal
- `gpatch`,
- and `diffutils`.

You should also create aliases for `realpath` and `patch`:

```sh
brew install coreutils # contains grealpath
brew install gpatch
brew install diffutils
Copy link
Collaborator

@infomiho infomiho May 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about the diffutils? I believe they should also be installed with brew to get the correct behavior?

What about grealpath?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should return install code block. It was part of aliases so I automatically discarded it.
Above is still mentioned to install those deps though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's back.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to double check that realpath alias is no longer needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this without any aliases and it worked. Aliases don't work in shell scripts anyway. That is the reason this PR started:

Aliases and functions do not propagate to shell scripts

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah true, great then 👍 I wanted to be extra safe since I didn't conclude that it's okay to delete it myself.


echo 'alias realpath="grealpath"' >> ~/.zshrc
echo 'alias patch="gpatch"' >> ~/.zshrc
source ~/.zshrc
```

Make sure not to commit `app/` to git. It is currently (until we resolve this) not added to .gitignore because that messes up diffing for us.

### Blog (blog/)
Expand Down
15 changes: 14 additions & 1 deletion opensaas-sh/tools/dope.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@
# Allows you to easily create a diff between the two projects (base and derived), or to patch those diffs onto the base project to get the derived one.
# Useful when derived project has only small changes on top of base project and you want to keep it in a dir in the same repo as main project.

# Determine the patch command to use based on OS
PATCH_CMD="patch"
if [[ "$(uname)" == "Darwin" ]]; then
# On macOS, require gpatch to be installed
if command -v gpatch &> /dev/null; then
PATCH_CMD="gpatch"
else
echo "Error: GNU patch (gpatch) not found. On MacOS, this script requires GNU patch."
echo "Install it with: brew install gpatch"
exit 1
fi
fi

# List all the source files in the specified dir.
# "Source" files are any files that are not gitignored.
list_source_files() {
Expand Down Expand Up @@ -92,7 +105,7 @@ recreate_derived_dir() {

local patch_output
local patch_exit_code
patch_output=$(patch --no-backup-if-mismatch --merge "${DERIVED_DIR}/${derived_filepath}" < "${diff_filepath}")
patch_output=$("${PATCH_CMD}" --no-backup-if-mismatch --merge "${DERIVED_DIR}/${derived_filepath}" < "${diff_filepath}")
patch_exit_code=$?
if [ ${patch_exit_code} -eq 0 ]; then
echo "${patch_output}"
Expand Down