Open-source Languages & Tools for z/OS

 View Only
  • 1.  Bash Wiping Out Input

    Posted 10-05-2017 17:40

    Hi,

    When executing a shell script in the bash shell on USS, we found that the input from a read statement in the script returns nothing, even if the user has input some text.

    Script excerpt
    #!/bin/env bash

    echo -n "Please provide the application mnemonic and press [ENTER]: "
    read appMnemonic

    appMnemonic=$(echo “$appMnemonic” | tr ‘[:upper:]’ ‘[:lower:]’)
    echo “$appMnemonic”

    The appMnemonic variable in this script is just empty when the echo prints even if the user has typed in an alphanumeric value. We noticed that this was happening when the script is executed from the bash shell, works fine in standard shell. Because of this on of our directories was entirely clobbered.

    bash-4.3$ bash -version
    GNU bash, version 4.3.46(51)-release (i370-ibm-openedition)
    Copyright © 2013 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html



  • 2.  RE: Bash Wiping Out Input

    Posted 10-06-2017 07:57

    Hi Patrick,

    Thanks for reporting. We are not able to reproduce the issue, this script works properly on our system. We will investigate the problem.

    Which z/OS version do you use?
    Also run these command immediately after you have logged in USS:

    ps
    env | sort



  • 3.  RE: Bash Wiping Out Input

    Posted 10-11-2017 13:45

    Hi Tatyana,

    Following is the output of your commands

        bash-4.3$ ps
        PID TTY       TIME CMD
        164 ttyp0001  0:00 /usr/lpp/git/bin/bash
        16777631 ttyp0001  0:00 /bin/sh
        531 ttyp0001  0:00 /bin/ps
    
    bash-4.3$ env | sort
    CLASSPATH=:/usr/lpp/suf/classes
    GIT_EXEC_PATH=/usr/lpp/git/libexec/git-core
    GIT_SHELL=/usr/lpp/git/bin/bash
    GIT_TEMPLATE_DIR=/usr/lpp/git/share/git-core/templates
    HOME=/u/automount/zk005
    JAVA_HOME=/usr/lpp/java/IBM/
    LANG=C
    LIBPATH=/usr/lpp/git/lib/perl5/5.24.0/os390/CORE:/lib:/usr/lib:.
    LOGNAME=ZK005
    MAIL=/usr/mail/ZK005
    MANPATH=/usr/man/%L:/usr/lpp/git/man
    NLSPATH=/usr/lib/nls/msg/%L/%N
    PATH=/usr/lpp/git/bin:/bin:/usr/lpp/java/IBM/bin:.
    PERL5LIB=/usr/lpp/git/lib/perl5:
    PWD=/u/automount/zk005
    SHELL=/bin/sh
    SHLVL=1
    SSH_TTY=/dev/ttyp0001
    STEPLIB=SYS1.CEE.SCEERUN
    TERM=xterm
    TZ=EST5EDT
    USER=ZK005
    _=/bin/env
    _BPXK_AUTOCVT=ON
    _C89_CLIB_PREFIX=SYS1
    _C89_PLIB_PREFIX=SYS1.CEE
    _CC_CLIB_PREFIX=SYS1
    _CC_PLIB_PREFIX=SYS1.CEE
    _CEE_RUNOPTS=FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)
    _CXX_CLIB_PREFIX=SYS1
    _CXX_PLIB_PREFIX=SYS1.CEE
    _TAG_REDIR_ERR=txt
    _TAG_REDIR_IN=txt
    _TAG_REDIR_OUT=txt


  • 4.  RE: Bash Wiping Out Input

    Posted 10-11-2017 17:35

    I also noticed that this was happening when we ran the script sourced, for example:
    . testScript.sh
    rather than
    sh testScript.sh.



  • 5.  RE: Bash Wiping Out Input

    Posted 10-24-2017 02:48

    Could it be that this is works as designed.

    On my Linux system running your script as x.sh I get:

    % ./x.sh  
    Please provide the application mnemonic and press [ENTER]: 123
    ““123””
    % /tmp % . ./x.sh 
    Please provide the application mnemonic and press [ENTER]: 123
    ./x.sh:6: no matches found: ‘[:upper:]’
    “”


  • 6.  RE: Bash Wiping Out Input

    Posted 10-24-2017 02:54

    No I’m wrong. It works also when sourced, at least if the text I enter contains an upper case letter.

    On z/OS UNIX both work as well even if I enter digits only:

    $. ./x.sh
    Please provide the application mnemonic and press [ENTER]: 123
    ““123””
    

    z/OS bash is:

    $bash --version
    GNU bash, version 4.2.53(2)-release (i370-ibm-openedition)
    Copyright (C) 2011 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
    
    This is free software; you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.


  • 7.  RE: Bash Wiping Out Input

    Posted 10-24-2017 10:13

    Hi Manfred,

    Does the issue occur if all lowercase characters are entered?



  • 8.  RE: Bash Wiping Out Input

    Posted 10-24-2017 15:57
    $./x.sh
    Please provide the application mnemonic and press [ENTER]: abc
    ““abc””
    $. ./x.sh
    Please provide the application mnemonic and press [ENTER]: abc
    ““abc””
    

    Note, as shown before, that I use an older bash. Perhaps issues crept into the new version.



  • 9.  RE: Bash Wiping Out Input

    Posted 10-25-2017 07:01

    Hi Patrick,

    I write it again, we are not able to reproduce this issue. This is environment-dependent problem. And we are working on the elucidation of the causes.



  • 10.  RE: Bash Wiping Out Input

    Posted 10-25-2017 07:10

    Ticket for internal use