name: "Builtins: shopt"
cases:
  - name: "shopt defaults"
    ignore_whitespace: true # Spacing changes across versions
    min_oracle_version: 5.3 # Options changed in bash 5.3
    incompatible_os: ["fedora"] # Fedora enables "syslog-history" option
    stdin: |
      shopt | sort | grep -v extglob

  - name: "shopt interactive defaults"
    ignore_whitespace: true # Spacing changes across versions
    min_oracle_version: 5.3 # Options changed in bash 5.3
    incompatible_os: ["fedora"] # Fedora enables "syslog-history" option
    pty: true
    args: ["-i", "-c", "shopt | sort | grep -v extglob"]

  - name: "shopt -o defaults"
    ignore_whitespace: true # Spacing changes across versions
    min_oracle_version: 5.3 # Options changed in bash 5.3
    stdin: |
      shopt -o | sort

  - name: "shopt -o interactive defaults"
    ignore_whitespace: true # Spacing changes across versions
    min_oracle_version: 5.3 # Options changed in bash 5.3
    pty: true
    args: ["-i", "-c", "shopt -o | sort | grep -v monitor"]

  - name: "extglob defaults"
    known_failure: true # TODO(patterns): we force this setting on in our shell
    stdin: |
      shopt extglob

  - name: "extglob interactive defaults"
    pty: true
    args: ["-i", "-c", "shopt extglob"]
    known_failure: true

  - name: "shopt -o interactive monitor default"
    ignore_whitespace: true # Spacing changes across versions
    min_oracle_version: 5.3 # Options changed in bash 5.3
    pty: true
    args: ["-i", "-c", "shopt -o monitor"]

  - name: "shopt toggle"
    ignore_whitespace: true # Spacing changes across versions
    stdin: |
      echo "Setting checkwinsize"
      shopt -s checkwinsize

      echo "Displaying checkwinsize"
      shopt checkwinsize
      shopt -p checkwinsize

      echo "Unsetting checkwinsize"
      shopt -u checkwinsize

      echo "Displaying checkwinsize"
      shopt checkwinsize
      shopt -p checkwinsize

  - name: "shopt -o usage"
    ignore_whitespace: true # Spacing changes across versions
    stdin: |
      echo "Setting emacs"
      shopt -o -s emacs

      echo "Displaying emacs"
      shopt -o emacs
      shopt -o -p emacs

      echo "Unsetting emacs"
      shopt -o -u emacs

      echo "Displaying emacs"
      shopt -o emacs
      shopt -o -p emacs
