Skip to main content
Lionel Dyck
Participating Frequently
Jan 28, 2021 12:26 PM UTC

bash anomaly

While using bash with the command:  env | sort > env.txt

the env.txt is tagged as ISO8859-1

BUT when using the /bin/sh shell with the same command the file is tagged as IBM-1047

Pertinent entries from the env results:

_BPXK_AUTOCVT=ON
_CEE_RUNOPTS=FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)
_TAG_REDIR_ERR=txt
_TAG_REDIR_IN=txt
_TAG_REDIR_OUT=txt

On this LPAR a cat of the ISO-8859-1 file while in /bin/sh results in what looks like ascii while under bash it displays fine.

On another LPAR - same profile (env) values the files have the same tags but a cat will work with both to display something usable.

???

------------------------------
Lionel Dyck
lbdyck
------------------------------

    6 replies

    Vladimir Ein
    Rocketeer
    Jan 28, 2021 2:17 PM UTC
    While using bash with the command:  env | sort > env.txt

    the env.txt is tagged as ISO8859-1

    BUT when using the /bin/sh shell with the same command the file is tagged as IBM-1047

    Pertinent entries from the env results:

    _BPXK_AUTOCVT=ON
    _CEE_RUNOPTS=FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)
    _TAG_REDIR_ERR=txt
    _TAG_REDIR_IN=txt
    _TAG_REDIR_OUT=txt

    On this LPAR a cat of the ISO-8859-1 file while in /bin/sh results in what looks like ascii while under bash it displays fine.

    On another LPAR - same profile (env) values the files have the same tags but a cat will work with both to display something usable.

    ???

    ------------------------------
    Lionel Dyck
    lbdyck
    ------------------------------
    Hello Lionel,

    If you issue the following command, does it display the same results on both systems/both shells?

    od -h -N 10 env.txt

    Thanks,
    Vladimir

    ------------------------------
    Vladimir Ein
    Rocket Software
    ------------------------------
    Lionel Dyck
    Participating Frequently
    Jan 28, 2021 2:25 PM UTC
    Hello Lionel,

    If you issue the following command, does it display the same results on both systems/both shells?

    od -h -N 10 env.txt

    Thanks,
    Vladimir

    ------------------------------
    Vladimir Ein
    Rocket Software
    ------------------------------

    Using /bin/sh:

     

    Good lpar:

     

    t IBM-1047    T=on  -rw-r--r--   1 LIONELD  SUDOGRP     1066 Jan 28 12:24 env.txt   

    t ISO8859-1   T=on  -rw-r--r--   1 LIONELD  SUDOGRP     1089 Jan 28 12:24 env1.txt  

    /u/lioneld>od -h -N 10 env.txt                                                       

    0000000000    C3  D3  C1  E2  E2  D7  C1  E3  C8  7E                                

    0000000012                                                                          

    /u/lioneld>od -h -N 10 env1.txt                                                      

    0000000000    43  4C  41  53  53  50  41  54  48  3D                                

    0000000012                                                                          

     

    Bad lpar:

     

    t ISO8859-1   T=on  -rw-r--r--   1 LBDYCK   ZOWEDEV     1922 Jan 28 12:16 env.txt  

    t IBM-1047    T=on  -rw-r--r--   1 LBDYCK   ZOWEDEV     1900 Jan 28 12:17 env1.txt 

    /u/lbdyck>od -h -N 10 env.txt                            

    0000000000    41  4F  50  43  4F  4E  46  3D  2F  65     

    0000000012                                                

    /u/lbdyck>od -h -N 10 env1.txt                           

    0000000000    C1  D6  D7  C3  D6  D5  C6  7E  61  85     

    0000000012                                               

     

    The results are the same whether under /bin/sh or using /usr/local/git/bin/bash  

     

    Lionel B. Dyck <sdg><

    Website: https://www.lbdsoftware.com

     

    "Worry more about your character than your reputation.  Character is what you are, reputation merely what others think you are." - John Wooden

     


    Vladimir Ein
    Rocketeer
    Jan 28, 2021 2:36 PM UTC

    Using /bin/sh:

     

    Good lpar:

     

    t IBM-1047    T=on  -rw-r--r--   1 LIONELD  SUDOGRP     1066 Jan 28 12:24 env.txt   

    t ISO8859-1   T=on  -rw-r--r--   1 LIONELD  SUDOGRP     1089 Jan 28 12:24 env1.txt  

    /u/lioneld>od -h -N 10 env.txt                                                       

    0000000000    C3  D3  C1  E2  E2  D7  C1  E3  C8  7E                                

    0000000012                                                                          

    /u/lioneld>od -h -N 10 env1.txt                                                      

    0000000000    43  4C  41  53  53  50  41  54  48  3D                                

    0000000012                                                                          

     

    Bad lpar:

     

    t ISO8859-1   T=on  -rw-r--r--   1 LBDYCK   ZOWEDEV     1922 Jan 28 12:16 env.txt  

    t IBM-1047    T=on  -rw-r--r--   1 LBDYCK   ZOWEDEV     1900 Jan 28 12:17 env1.txt 

    /u/lbdyck>od -h -N 10 env.txt                            

    0000000000    41  4F  50  43  4F  4E  46  3D  2F  65     

    0000000012                                                

    /u/lbdyck>od -h -N 10 env1.txt                           

    0000000000    C1  D6  D7  C3  D6  D5  C6  7E  61  85     

    0000000012                                               

     

    The results are the same whether under /bin/sh or using /usr/local/git/bin/bash  

     

    Lionel B. Dyck <sdg><

    Website: https://www.lbdsoftware.com

     

    "Worry more about your character than your reputation.  Character is what you are, reputation merely what others think you are." - John Wooden

     


    Let's re-check if I got it right. When all of this is true, you get garbage - correct?

    1. You do 'cat env.txt' with the ISO8859-1 tagged file
    2. This happens on the 'bad' LPAR
    3. The command is invoked under /bin/sh

    And in all other cases, the file contents is displayed correctly - did I get it right?

    If so, I'd say that for some reason, /bin/sh on the 'bad' LPAR disables auto-conversion, while in all other cases conversion is enabled.

    Judging by 'od -h' output, file contents does match its tag in all cases, so at least there are no problems with the files themselves.

    Also, do you have the _TEXT_CONV variable in your environment?

    ------------------------------
    Vladimir Ein
    Rocket Software
    ------------------------------
    Lionel Dyck
    Participating Frequently
    Jan 28, 2021 2:44 PM UTC
    Let's re-check if I got it right. When all of this is true, you get garbage - correct?

    1. You do 'cat env.txt' with the ISO8859-1 tagged file
    2. This happens on the 'bad' LPAR
    3. The command is invoked under /bin/sh

    And in all other cases, the file contents is displayed correctly - did I get it right?

    If so, I'd say that for some reason, /bin/sh on the 'bad' LPAR disables auto-conversion, while in all other cases conversion is enabled.

    Judging by 'od -h' output, file contents does match its tag in all cases, so at least there are no problems with the files themselves.

    Also, do you have the _TEXT_CONV variable in your environment?

    ------------------------------
    Vladimir Ein
    Rocket Software
    ------------------------------

    You got it right.

     

    No _TEXT_CONV

     

    Lionel B. Dyck <sdg><

    Website: https://www.lbdsoftware.com

     

    "Worry more about your character than your reputation.  Character is what you are, reputation merely what others think you are." - John Wooden

     


    Lionel Dyck
    Participating Frequently
    Jan 28, 2021 3:06 PM UTC
    Let's re-check if I got it right. When all of this is true, you get garbage - correct?

    1. You do 'cat env.txt' with the ISO8859-1 tagged file
    2. This happens on the 'bad' LPAR
    3. The command is invoked under /bin/sh

    And in all other cases, the file contents is displayed correctly - did I get it right?

    If so, I'd say that for some reason, /bin/sh on the 'bad' LPAR disables auto-conversion, while in all other cases conversion is enabled.

    Judging by 'od -h' output, file contents does match its tag in all cases, so at least there are no problems with the files themselves.

    Also, do you have the _TEXT_CONV variable in your environment?

    ------------------------------
    Vladimir Ein
    Rocket Software
    ------------------------------

    I just logged off and back on (network outage at the house) and tried things again and the 'env | sort > env.txt' still creates the different tagged files but cat works ok with either under both /bin/sh and /u/lbdyck/miniconda/bin/bash 

     

    t IBM-1047    T=on  -rw-r--r--   1 LBDYCK   ZOWEDEV     1900 Jan 28 14:58 env.txt     

    t ISO8859-1   T=on  -rw-r--r--   1 LBDYCK   ZOWEDEV     1967 Jan 28 14:58 envb.txt    

     

    Confused I am....

     

    I'm still trying to figure out this error:

     

    /u/lbdyck>git clone git@github.com:lbdyck/racfadm.git   

    Cloning into 'racfadm'...                               

    fatal: protocol error: bad line length character: ---Á  

     

    I suspect when I solve one that it will resolve the other.

     

    Lionel B. Dyck <sdg><

    Website: https://www.lbdsoftware.com

     

    "Worry more about your character than your reputation.  Character is what you are, reputation merely what others think you are." - John Wooden

     


    Vladimir Ein
    Rocketeer
    Jan 28, 2021 3:27 PM UTC

    I just logged off and back on (network outage at the house) and tried things again and the 'env | sort > env.txt' still creates the different tagged files but cat works ok with either under both /bin/sh and /u/lbdyck/miniconda/bin/bash 

     

    t IBM-1047    T=on  -rw-r--r--   1 LBDYCK   ZOWEDEV     1900 Jan 28 14:58 env.txt     

    t ISO8859-1   T=on  -rw-r--r--   1 LBDYCK   ZOWEDEV     1967 Jan 28 14:58 envb.txt    

     

    Confused I am....

     

    I'm still trying to figure out this error:

     

    /u/lbdyck>git clone git@github.com:lbdyck/racfadm.git   

    Cloning into 'racfadm'...                               

    fatal: protocol error: bad line length character: ---Á  

     

    I suspect when I solve one that it will resolve the other.

     

    Lionel B. Dyck <sdg><

    Website: https://www.lbdsoftware.com

     

    "Worry more about your character than your reputation.  Character is what you are, reputation merely what others think you are." - John Wooden

     


    The fact that env*.txt files are tagged differently is normal - bash tags output streams as ISO8859-1 right on creation whereas sh marks them to be tagged on first write (so-called 'deferred tagging'). Sh only does that if _TAG_REDIR_OUT is set to 'txt'. And yes, the input / output / error streams are created by the shell.

    Since 'sort' is an EBCDIC program, the file gets tagged as IBM-1047 under sh.

    ------------------------------
    Vladimir Ein
    Rocket Software
    ------------------------------