Skip to content

Commit

Permalink
symlink-cpp-lint-configs.sh: Replace realpath with equivalent to su…
Browse files Browse the repository at this point in the history
…pport macOS. (#9)
  • Loading branch information
kirkrodrigues authored Sep 9, 2024
1 parent 536af8e commit 2caa3dc
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lint-configs/symlink-cpp-lint-configs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,16 @@ symlink_config () {
config_file_path="$1"

repo_dir="$(git rev-parse --show-toplevel)"
repo_relative_config_file_path="$(realpath --relative-to="$repo_dir" "$config_file_path")"
config_file_absolute_path="$(readlink -f "$config_file_path")"

# Ensure $repo_dir has a single trailing slash
repo_dir="${repo_dir%/}/"

# Get the config file's path relative to the repo root
# NOTE: This is a bit fragile since it depends on $repo_dir having a single trailing slash.
# Ideally, we would use `realpath --relative-to` instead of variable substitution, but
# `--relative-to` isn't available on macOS.
repo_relative_config_file_path="${config_file_absolute_path#"${repo_dir}"}"

src_path="${repo_dir}/${repo_relative_config_file_path}"
dst_path="${repo_dir}/$(basename "$config_file_path")"
Expand Down

0 comments on commit 2caa3dc

Please sign in to comment.