Skip to content

fix: improve op-run.sh script robustness #9861

@luojiyin1987

Description

@luojiyin1987

Problem

The development/scripts/op-run.sh script has several issues:

  1. No argument checking: Running the script without parameters causes exec "$@" to fail
  2. Invalid variable names: Items from 1Password with titles starting with numbers create invalid shell variable names (e.g., 3RD_PARTY_API_KEY)
  3. Missing error handling: Using set -e only, missing -u (undefined variables) and -o pipefail options
  4. Unsafe string handling: Using echo which may interpret escape sequences in item titles

Solution

  • Add usage prompt when no arguments provided
  • Skip items whose sanitized names start with numbers
  • Use set -euo pipefail for stricter error handling
  • Use printf '%s' instead of echo for safer string handling
  • Fix jq null handling when no matching account found

Impact

  • Prevents script failures when called incorrectly
  • Avoids export errors from invalid variable names
  • More robust error handling throughout the script

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions