| 1 | 
  
    ## oils_failures_allowed: 4
   | 
  | 2 | 
  
    ## compare_shells: bash dash mksh zsh
   | 
  | 3 | 
  
    
   | 
  | 4 | 
  
    
   | 
  | 5 | 
  
    # POSIX rule about special builtins pointed at:
   | 
  | 6 | 
  
    #
   | 
  | 7 | 
  
    # https://www.reddit.com/r/oilshell/comments/5ykpi3/oildev_is_alive/
   | 
  | 8 | 
  
    
   | 
  | 9 | 
  
    
   | 
  | 10 | 
  
    case $SH in
   | 
  | 11 | 
  
      dash|zsh|*osh)
   | 
  | 12 | 
  
        ;;
   | 
  | 13 | 
  
      *)
   | 
  | 14 | 
  
        # for bash
   | 
  | 15 | 
  
        set -o posix
   | 
  | 16 | 
  
        ;;
   | 
  | 17 | 
  
    esac
   | 
  | 18 | 
  
    foo=bar :
   | 
  | 19 | 
  
    echo foo=$foo
   | 
  | 20 | 
  
    ## STDOUT:
   | 
  | 21 | 
  
    foo=bar
   | 
  | 22 | 
  
    ## END
   | 
  | 23 | 
  
    ## BUG zsh STDOUT:
   | 
  | 24 | 
  
    foo=
   | 
  | 25 | 
  
    ## END
   | 
  | 26 | 
  
    
   | 
  | 27 | 
  
    
   | 
  | 28 | 
  
    
   | 
  | 29 | 
  
    # Bash only implements it behind the posix option
   | 
  | 30 | 
  
    case $SH in
   | 
  | 31 | 
  
      dash|zsh|*osh)
   | 
  | 32 | 
  
        ;;
   | 
  | 33 | 
  
      *)
   | 
  | 34 | 
  
        # for bash
   | 
  | 35 | 
  
        set -o posix
   | 
  | 36 | 
  
        ;;
   | 
  | 37 | 
  
    esac
   | 
  | 38 | 
  
    foo=bar readonly spam=eggs
   | 
  | 39 | 
  
    echo foo=$foo
   | 
  | 40 | 
  
    echo spam=$spam
   | 
  | 41 | 
  
    
   | 
  | 42 | 
  
    # should NOT be exported
   | 
  | 43 | 
  
    printenv.py foo
   | 
  | 44 | 
  
    printenv.py spam
   | 
  | 45 | 
  
    ## STDOUT:
   | 
  | 46 | 
  
    foo=bar
   | 
  | 47 | 
  
    spam=eggs
   | 
  | 48 | 
  
    None
   | 
  | 49 | 
  
    None
   | 
  | 50 | 
  
    ## END
   | 
  | 51 | 
  
    ## BUG bash STDOUT:
   | 
  | 52 | 
  
    foo=bar
   | 
  | 53 | 
  
    spam=eggs
   | 
  | 54 | 
  
    bar
   | 
  | 55 | 
  
    None
   | 
  | 56 | 
  
    ## END
   | 
  | 57 | 
  
    
   | 
  | 58 | 
  
    
   | 
  | 59 | 
  
    foo=bar true
   | 
  | 60 | 
  
    echo $foo
   | 
  | 61 | 
  
    ## stdout:
   | 
  | 62 | 
  
    
   | 
  | 63 | 
  
    
   | 
  | 64 | 
  
    test -n "$BASH_VERSION" && set -o posix
   | 
  | 65 | 
  
    set -- a b
   | 
  | 66 | 
  
    shift 3
   | 
  | 67 | 
  
    echo status=$?
   | 
  | 68 | 
  
    ## stdout-json: ""
   | 
  | 69 | 
  
    ## status: 1
   | 
  | 70 | 
  
    ## OK dash status: 2
   | 
  | 71 | 
  
    ## BUG bash/zsh status: 0
   | 
  | 72 | 
  
    ## BUG bash/zsh STDOUT:
   | 
  | 73 | 
  
    status=1
   | 
  | 74 | 
  
    ## END
   | 
  | 75 | 
  
    
   | 
  | 76 | 
  
    
   | 
  | 77 | 
  
    shopt -s invalid_ || true
   | 
  | 78 | 
  
    echo ok
   | 
  | 79 | 
  
    set -o invalid_ || true
   | 
  | 80 | 
  
    echo should not get here
   | 
  | 81 | 
  
    ## STDOUT:
   | 
  | 82 | 
  
    ok
   | 
  | 83 | 
  
    ## END
   | 
  | 84 | 
  
    ## status: 1
   | 
  | 85 | 
  
    ## OK dash status: 2
   | 
  | 86 | 
  
    ## BUG bash status: 0
   | 
  | 87 | 
  
    ## BUG bash STDOUT:
   | 
  | 88 | 
  
    ok
   | 
  | 89 | 
  
    should not get here
   | 
  | 90 | 
  
    ## END
   | 
  | 91 | 
  
    
   | 
  | 92 | 
  
    
   | 
  | 93 | 
  
    # bash manual says they are 'found before' functions.
   | 
  | 94 | 
  
    test -n "$BASH_VERSION" && set -o posix
   | 
  | 95 | 
  
    export() {
   | 
  | 96 | 
  
      echo 'export func'
   | 
  | 97 | 
  
    }
   | 
  | 98 | 
  
    export hi
   | 
  | 99 | 
  
    echo status=$?
   | 
  | 100 | 
  
    ## status: 2
   | 
  | 101 | 
  
    ## BUG mksh/zsh status: 0
   | 
  | 102 | 
  
    ## BUG mksh/zsh stdout: status=0
   | 
  | 103 | 
  
    
   | 
  | 104 | 
  
    
   | 
  | 105 | 
  
    test -n "$BASH_VERSION" && set -o posix
   | 
  | 106 | 
  
    true() {
   | 
  | 107 | 
  
      echo 'true func'
   | 
  | 108 | 
  
    }
   | 
  | 109 | 
  
    true hi
   | 
  | 110 | 
  
    echo status=$?
   | 
  | 111 | 
  
    ## STDOUT:
   | 
  | 112 | 
  
    true func
   | 
  | 113 | 
  
    status=0
   | 
  | 114 | 
  
    ## END
   | 
  | 115 | 
  
    
   | 
  | 116 | 
  
    
   | 
  | 117 | 
  
    
   | 
  | 118 | 
  
    case $SH in dash) exit ;; esac
   | 
  | 119 | 
  
    
   | 
  | 120 | 
  
    builtin echo b
   | 
  | 121 | 
  
    command echo c
   | 
  | 122 | 
  
    
   | 
  | 123 | 
  
    builtin() {
   | 
  | 124 | 
  
      echo builtin-redef "$@"
   | 
  | 125 | 
  
    }
   | 
  | 126 | 
  
    
   | 
  | 127 | 
  
    command() {
   | 
  | 128 | 
  
      echo command-redef "$@"
   | 
  | 129 | 
  
    }
   | 
  | 130 | 
  
    
   | 
  | 131 | 
  
    builtin echo b
   | 
  | 132 | 
  
    command echo c
   | 
  | 133 | 
  
    
   | 
  | 134 | 
  
    ## STDOUT:
   | 
  | 135 | 
  
    b
   | 
  | 136 | 
  
    c
   | 
  | 137 | 
  
    builtin-redef echo b
   | 
  | 138 | 
  
    command-redef echo c
   | 
  | 139 | 
  
    ## END
   | 
  | 140 | 
  
    ## N-I dash STDOUT:
   | 
  | 141 | 
  
    ## END
   |