core/tsrc/fshell-last-test.script
changeset 0 7f656887cf89
equal deleted inserted replaced
-1:000000000000 0:7f656887cf89
       
     1 #!fshell
       
     2 # fshell-last-test.script
       
     3 # 
       
     4 # Copyright (c) 2010 Accenture. All rights reserved.
       
     5 # This component and the accompanying materials are made available
       
     6 # under the terms of the "Eclipse Public License v1.0"
       
     7 # which accompanies this distribution, and is available
       
     8 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     9 # 
       
    10 # Initial Contributors:
       
    11 # Accenture - Initial contribution
       
    12 #
       
    13 
       
    14 # Test that the behaviour of the 'last' attribute behaves the way we expect, in various awkward cases involving pipes and pipelines
       
    15 
       
    16 source $SCRIPT_PATH\errordef.script
       
    17 
       
    18 export TEST_TEXT "Something with spaces and 'inner quotes' and --options"
       
    19 
       
    20 echo -n "Something with spaces and 'inner quotes' and --options" | export -s RESULT
       
    21 var RESULT == "$TEST_TEXT" || $Error
       
    22 
       
    23 echo -n Something with spaces and 'inner quotes' and --options | export -s RESULT
       
    24 var RESULT == "$TEST_TEXT" || $Error
       
    25 
       
    26 fshell -e "echo -n a && echo -n b" | export -s RESULT
       
    27 var RESULT == "ab" || $Error
       
    28 
       
    29 repeat 1 "fshell -e 'echo -n c && echo -n d'" | export -s RESULT
       
    30 var RESULT == "cd" || $Error
       
    31 
       
    32 repeat 3 echo a && echo b | export -s RESULT
       
    33 var RESULT == b^r^n || $Error # Apparently pipe only operates on a single pipeline stage
       
    34 
       
    35 # Put the repeat inside an fshell -e merely so we can pipe the whole lot into export
       
    36 fshell -e "repeat 3 echo -n a && echo -n b" | export -s RESULT
       
    37 var RESULT == aaab || $Error # last doesn't include &&
       
    38 
       
    39 fshell -e "repeat 3 'echo -n a && echo -n b'" | export -s RESULT
       
    40 var RESULT == ababab || $Error
       
    41 
       
    42 fshell -e "repeat 1 echo -n 'quotation ^^'soup^^''" | export -s RESULT
       
    43 var RESULT == "quotation 'soup'" || $Error
       
    44 
       
    45 export ARG1 "Arg 1"
       
    46 export ARG2 "2222"
       
    47 export ARG3 "Arg '3' has inner quotes"
       
    48 fshell $SCRIPT_PATH\checkargs.script "Arg 1" 2222 "Arg '3' has inner quotes"
       
    49 
       
    50 # Check that escape sequences inside a "last" command are handled correctly (ie aren't expanded)
       
    51 echo hello ^t world | export -s RESULT
       
    52 var RESULT == "hello ^^t world^r^n" || $Error
       
    53 
       
    54 # Check that variable expansion inside a "last" command is handled correctly
       
    55 echo -n dollar questionmark is: $? | export -s RESULT
       
    56 var RESULT == "dollar questionmark is: 0" || $Error