← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:simplify-rocketfuel-symlink-checks into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:simplify-rocketfuel-symlink-checks into launchpad:master.

Commit message:
Simplify symlink checks in rocketfuel-setup

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/420298

`shellcheck` complains of two places in `rocketfuel-setup`:

    SC2012 (info): Use find instead of ls to better handle non-alphanumeric filenames.

I don't think its proposed solution is best in this case, but it has a point about the problem: parsing the output of `ls -l` is pretty clunky.  We know exactly what we expect these two symlinks to point to, so test them directly using `readlink` instead.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:simplify-rocketfuel-symlink-checks into launchpad:master.
diff --git a/utilities/rocketfuel-setup b/utilities/rocketfuel-setup
index a0d27d2..6d18b8a 100755
--- a/utilities/rocketfuel-setup
+++ b/utilities/rocketfuel-setup
@@ -292,14 +292,14 @@ cd /usr/local/bin || exit 1
 if [ ! -e rocketfuel-get ]; then
   sudo ln -s "$LP_TRUNK_PATH/utilities/rocketfuel-get"
 fi
-if ! ls -l rocketfuel-get | cut -d">" -f2 | grep -q "$LP_TRUNK_NAME\/utilities\/rocketfuel"; then
+if [ "$(readlink rocketfuel-get)" != "$LP_TRUNK_PATH/utilities/rocketfuel-get" ]; then
   echo "WARNING: /usr/local/bin/rocketfuel-get should be deleted so I can
          recreate it."
 fi
 if [ ! -e rocketfuel-setup ]; then
   sudo ln -s "$LP_TRUNK_PATH/utilities/rocketfuel-setup"
 fi
-if ! ls -l rocketfuel-setup | cut -d">" -f2 | grep -q "$LP_TRUNK_NAME\/utilities\/rocketfuel"; then
+if [ "$(readlink rocketfuel-setup)" != "$LP_TRUNK_PATH/utilities/rocketfuel-setup" ]; then
   echo "WARNING: /usr/local/bin/rocketfuel-setup should be deleted so I can
          recreate it."
 fi