Skip to content

Commit 9c25f3d

Browse files
committed
Fixes AutoTST installation on BSD sed
Ensures compatibility of the AutoTST installation script with both GNU and BSD versions of `sed`. It achieves this by conditionally including an empty string in the `sed -i` command for BSD systems, which require it.
1 parent 9efbf95 commit 9c25f3d

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

devtools/install_autotst.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,13 @@ autotst_off () {
173173
# Enable AutoTST by default in new shells and keep RMG-Py out of the way.
174174
autotst_on
175175
EOF
176-
# replace placeholder with actual path
177-
sed -i "s#__AUTOTST_PATH__#$(pwd | sed 's#/#\\\\/#g')#" ~/.bashrc
176+
# replace placeholder with actual path (portable across GNU/BSD sed)
177+
AUTOTST_ESCAPED_PATH="$(pwd | sed 's#/#\\\\/#g')"
178+
if sed --version >/dev/null 2>&1; then
179+
sed -i "s#__AUTOTST_PATH__#${AUTOTST_ESCAPED_PATH}#" ~/.bashrc
180+
else
181+
sed -i '' "s#__AUTOTST_PATH__#${AUTOTST_ESCAPED_PATH}#" ~/.bashrc
182+
fi
178183
echo "✔️ Added AutoTST path-mode hook to ~/.bashrc"
179184
else
180185
echo "ℹ️ AutoTST path-mode hook already exists in ~/.bashrc"

0 commit comments

Comments
 (0)