Skip to content

Bug Caused by sed ReplacementΒ #1

@mvastola

Description

@mvastola

Hi,,
So I wanted to try out this package and ran into a problem with the Makefile. Specifically, make install runs sed -i.bak 's|SCRIPT_DIR.*|SPINNERS_JSON="/usr/local/share/bash-cli-spinners/spinners.json"|' /usr/local/bin/spinner.

I'm not exactly sure what change this command was intended to make, but in its current state, the sed command modifies the copy of spinner.sh in /usr/local/bin/spinner such that these two lines

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SPINNERS_JSON="$SCRIPT_DIR/spinners.json"

change into

SPINNERS_JSON="/usr/local/share/bash-cli-spinners/spinners.json"
SPINNERS_JSON="$SPINNERS_JSON="/usr/local/share/bash-cli-spinners/spinners.json"

...which isn't syntactically correct (causing the script to abort before it does anything) and can't be what was intended. (Maybe there was an earlier version of spinner.sh where the replacement regex did what was intended?

While I'm not 100% sure what the author was going for, if it helps, here are two possible ways to make the script work:

  1. Remove the sed command from the Makefile and replace the SCRIPT_DIR=... line in spinner.sh with

    for SCRIPT_DIR in "$(dirname "${BASH_SOURCE[0]}")" /usr/local/share/bash-cli-spinners; do
        [ -f "${SCRIPT_DIR}/spinners.json" ] && break
    done
  2. Change the sed command to something like

    sed -i.bak 's|^\s*SCRIPT_DIR=.*$$|SCRIPT_DIR="/usr/local/share/bash-cli-spinners"|' /usr/local/bin/spinner

    (Note: the $$ is how you escape a $ in a Makefile)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions