bug#38082: 'tr' question passing tr delete chars argument coded in hex into script as $varable
To: bug-coreutils.org From: Owen Townsend, o...@uvsoftware.ca Date: Nov.05/2019 Subject: 'tr' question passing tr delete chars argument coded in hex into script as $varable I am attaching 2 scripts renameLNX & renameLNX1 renameLNX - delete characters hard-coded on tr - works OK renameLNX1 - delete characters passed as $variable from cmdline argument - does not work - is this a bug OR is something wrong with my coding ??? renameLNX1 dirxx '\x20\x21\x27\x28\x29\x2C' #<-- passing hex delete chars cmdline argument fn2=$(echo $fn1 | tr -d $"$chars") #<-- does not work See test results coded as #comments at end of attached renameLNX1 script fn2=$(echo $fn1 | tr -d $'\x21\x24\x26\x27\x28\x29\x2A\x2C') #<-- hard-coded hex deletes OK See script renameLNX OK Is this a bug OR is something wrong with my coding ??? Thanks, Owen #!/bin/bash # renameLNX - Korn shell script from UVSI stored in: /home/uvadm/sf/util/ # renameLNX - rename all files in directory to Linux filenaming conventions # - Deleting characters in filenames that must be escaped on Linux systems # - also removing LowBit & HiBit characters using complement option & octal codes # renameLNX1 - original script did not work trying to use "$chars" on the 'tr' command # renameLNX - this HARD-CODEs the HEX chars to be deleted on the 'tr' command & it works # - can anyone tell me how to make "$chars" work on the 'tr' command ??? # echo "rename files in subdir - deleting characters that must be escaped on Linux" dir="$1"; chars="$2"; if [[ -d "$dir" ]]; then : else echo "usage: renameLNX directory " echo " " echo " - arg1=directory, arg2=CharactersToDelete " echo " - arg2 removed for renameLNX, hard-coded on 'tr' comamnd below" echo "\x20\x21\x22\x24\x26\x27\x28\x29\x2A\x2C\x3A\x3B\x3C\x3E\x3F\x5B\x5C\x5D\x7B\x7C\x7D" echo "space \! \" \$ \& \' \( \) \* , : ; < > \? [ \\ ] { | }" exit 1; fi # reply="n" until [ "$reply" = "y" ] do echo "enter to rename files ? y/n" read reply done x=0; y=0 for dfn in $dir/* do fn1=${dfn##*/} fn2=$(echo $fn1 | tr -cd '\12\40-\176') #remove LowBit&HiBit chars (octal, hex bug optn 'c') fn3=$(echo $fn2 | tr -d \ $'\x20\x21\x22\x24\x26\x27\x28\x29\x2A\x2C\x3A\x3B\x3C\x3E\x3F\x5B\x5C\x5D\x7B\x7C\x7D') #= HARD-CODED == # echo "Debug: fn1=$fn1 fn3=$fn3" let x=x+1 if [[ $fn1 == $fn3 ]]; then continue; fi mv -i "$dir/$fn1" "$dir/$fn3" let y=y+1 echo "file# $x $dir/$fn1 - renamed to: $dir/$fn3" done echo "total $x files, $y renamed (deleting $chars)" exit 0 #*eject # test renameLNX deletes hardcoded (vs renameLNX1 deletes arg2 & $chars on tr) --- # renameLNX dirxx #- input - # file#1=comma=,leftparen=(,rightparen=),exclamation=! # file#2=blanks comma=, leftparen=(, rightparen=), exclamation=! # file#3-exclam=!,dollar=$,amp=&,quotes='",parens=(),star=*,comma=, # - renameLNX output OK if deletes hardoded - # file#1=comma=leftparen=rightparen=exclamation= # file#2=blankscomma=leftparen=rightparen=exclamation= <-- renameLNX hard-coded OK # file#3-exclam=dollar=amp=quotes=parens=star=comma= # #Note - Also see "renameLNX1" alternate script, deletes as arg2, coded on tr as $chars # # - renameLNX1 output BAD when deletes on arg2 & $chars on tr - # file#3-eclam=!,dollar=$,amp=&,quotes='",parens=(),star=*,comma=, # file#=blanks comma=, leftparen=(, rightparen=), eclamation=! <-- renameLNX1 NOT working # file#=comma=,leftparen=(,rightparen=),eclamation=! - $arg2 passed to tr ??? # #Note - characters 1,2,x are removed - why is HEX not recognized # - BUT it works if I hard code the 'tr' line as follows: # fn2=$(echo $fn1 | tr -d $'\x21\x24\x26\x27\x28\x29\x2A\x2C') # #=== # # Why Hard-Coding on 'tr' works, but not substituting as in renameLNX1 ??? # renameLNX1 dirxx '\x20\x21\x22...etc...' <-- renameLNX1 deletes arg2 (tr -d \$"$chars") # #fn3=$(echo $fn1 | tr -d \$"$chars")<-- $arg2 on tr does NOT work ??? ##== #!/bin/bash # renameLNX1 - Korn shell script from UVSI stored in: /home/uvadm/sf/util/ # renameLNX1 - rename an entir
bug#38080: 'tr' BUG using complement option with delete chars in HEX vs OCTAL
To: bug-coreutils.org From: Owen Townsend, o...@uvsoftware.ca Date: Nov.05/2019 Subject: 'tr' BUG using complement option with delete chars in HEX vs OCTAL fn2=$(echo $fn1 | tr -cd '\12\40-\176') #<-- OCTAL works, but HEX preferred fn2=$(echo $fn1 | tr -cd \$'\x0A\x20-\x7E') #<-- HEX does not work See attached scripts renameOK & renameOKx renameOK - octal coding, works OK renameOKx - HEX coding does NOT work - see test results coded as #comments at end of script Please let me know if you confirm this is a bug and when it might be fixed ? I am using Ubuntu 16.04 & plan to upgrade to 20.04 when available Thanks, Owen #!/bin/bash # renameOK - Korn shell script from UVSI stored in: /home/uvadm/sf/util/ # renameOK - rename all files in directory, using tr -cd & OCTAL characters (works OK) # - Deleting all LowBit (except LineFeed) & HighBit characters # renameOKx <-- Alternate script specifies delete chars in HEX, but does NOT work ??? # --> see $UV/sf/util/renameOKx with test results as #cmts at bottom #Note - must use 'bash' shell for HEX to work at all, but complement option not working in hex # echo "$0 - rename all files in directory Deleting LowBit (except LineFeed) & HighBit characters" dir="$1"; if [[ ! -d "$dir" ]]; then echo "usage: renameOK directory " echo " ===" echo " - arg1 must be a directory" exit 1; fi # reply="n" until [ "$reply" = "y" ] do echo "enter to rename files ? y/n" read reply done x=0; y=0 for dfn in $dir/* do fn1=${dfn##*/} fn2=$(echo $fn1 | tr -cd '\12\40-\176') #<-- OCTAL works, but HEX preferred # fn2=$(echo $fn1 | tr -cd \$'\x0A\x20-\x7E') #<-- HEX disabled, see renameOKx to test #Note - option 'c' of '-cd' COMPLEMENTS (deletes all characters not specified) # echo "Debug: fn1=$fn1 fn2=$fn2" let x=x+1 if [[ $fn1 == $fn2 ]]; then continue; fi mv -i "$dir/$fn1" $dir/$fn2 #== let y=y+1 echo "file# $x $dir/$fn1 - renamed to: $dir/$fn2" done echo "total $x files, $y renamed deleting LowBit (except LineFeed) & HighBit characters" exit 0 #!/bin/bash # renameOKx - Korn shell script from UVSI stored in: /home/uvadm/sf/util/ # renameOKx - rename directory of filenames <-- delete chars in HEX, does NOT work ??? # - Deleting all LowBit (except LineFeed) & HighBit characters # renameOK <-- Alternate version specifies delete chars in OCTAL & does work # renameOKx <-- This script specifies delete chars in HEX, but does NOT work - WHY NOT ??? # --> see test input/output at bottom #Note - must use 'bash' shell for HEX to work at all, but complement option not working in hex # echo "$0 - rename all files in directory Deleting LowBit (except LineFeed) & HighBit characters" dir="$1"; if [[ ! -d "$dir" ]]; then echo "usage: renameOKx directory " echo " ===" echo " - arg1 must be a directory" exit 1; fi # reply="n" until [ "$reply" = "y" ] do echo "enter to rename files ? y/n" read reply done x=0; y=0 for dfn in $dir/* do fn1=${dfn##*/} # fn2=$(echo $fn1 | tr -cd '\12\40-\176') #<-- octal obsolete & stupid fn2=$(echo $fn1 | tr -cd \$'\x0A\x20-\x7E') #<-- hex preferred, but has bugs ? #Note - option 'c' of '-cd' COMPLEMENTS (deletes chars not specified) # - does NOT work if chars specified in HEX, but OK if OCTAL - WHY diff ??? # echo "Debug: fn1=$fn1 fn2=$fn2" let x=x+1 if [[ $fn1 == $fn2 ]]; then continue; fi mv -i "$dir/$fn1" $dir/$fn2 #== let y=y+1 echo "file# $x $dir/$fn1 - renamed to: $dir/$fn2" done echo "total $x files, $y renamed deleting LowBit (except LineFeed) & HighBit characters" exit 0 # renameOKx tmp1 # == # # Original filenames in directory tmp1 # -rw-r- 1 uvadm apps 84335 Nov 5 08:09 Another.jpg # -rw-r- 1 uvadm apps 1500403 Nov 5 08:10 IMG_20170121_142512.jpg # -rw-r- 1 uvadm apps 48151 Nov 5 08:11 Mia - tomato% +head art.jpg # -rw-r- 1 uvadm apps 92384 Nov 5 09:11 My art: at^ _vsb |offices.jpg # # Resulting filenames after --> renameOKx tmp1 # -rw-r- 1 uvadm apps 84335 Nov 5 09:14 Anotherjpg # -rw-r- 1 uvadm apps 1500403 Nov 5 09:14 IMG_20170121_142512jpg # -rw-r- 1 uvadm apps 92384 Nov 5 09:14 Mart:at^_vsbofficesjpg # -rw-r- 1 uvadm apps 48151 Nov 5 09:14 Miatomatoheadartjpg # # renameOK tmp1 <-- Alternate script specifies delete chars in Octal works OK # =- why don't renameOKx HEX chars work ???
bug#12421: Issue of the cp on Ubuntu 10.10
Dear Sir, A strange issue happens when I use the cp tool on two directory. 1 I have an empty directiry owen@linux-b2-ali:~/work/ALi_SDK/DailyBuild/linux_20120911$ ls images/fs.install/ -a . .. 2 Then I cp an directory in this directory with -rf owen@linux-b2-ali:~/work/ALi_SDK/DailyBuild/linux_20120911$ cp extern/fs_install/* images/fs.install/ -rf We can find the file busybox size is 998K now. owen@linux-b2-ali:~/work/ALi_SDK/DailyBuild/linux_20120911$ ls images/fs.install/bin/busybox -lh -rwxr-xr-x 1 owen owen 988K 2012-09-11 21:37 images/fs.install/bin/busybox 3 In another directory, we have a same file with the same size owen@linux-b2-ali:~/work/ALi_SDK/DailyBuild/linux_20120911$ ls extern/fs.install/bin/busybox -lh -rwxr-xr-x 1 owen owen 988K 2012-09-11 15:02 extern/fs.install/bin/busybox 4 Copy the content of the extern/fs.install/bin/busybox to images/fs.install owen@linux-b2-ali:~/work/ALi_SDK/DailyBuild/linux_20120911$ cp extern/fs.install/* images/fs.install/ -rf 5 Check the size of busybox owen@linux-b2-ali:~/work/ALi_SDK/DailyBuild/linux_20120911$ ls images/fs.install/bin/busybox -lh -rwxr-xr-x 1 owen owen 526K 2012-09-11 21:39 images/fs.install/bin/busybox Anything I missed when I copy ? The size is changed dramatically. Best Regards Yours (Owen) *8652 * *18928021899 * * Just do it!*
bug#7320: 'group' command gives wrong/extra group
Hi, It appears that the 'groups' command doesn't get the list of groups for a currently-running process quite right. The conditions I tested were where the UID and EUID of the process were different, and the GID and EGID were both set to the primary group of the EUID. The groups command looked up the real user and added the primary group from /etc/passwd to the list of groups the user was in, even though the process had no permissions for this extra group. So, for example say /etc/passwd has at least these 2 entries: root:x:0:0:root:/root:/bin/sh user:x:1000:1000:user:/home/user:/bin/sh and /etc/group has at least these 3 entries: root:x:0: other:x:500: user:x:1000: If a process as UID=0, EUID=1000, GID=1000, and EGID=1000 and no supplemental groups, the correct list of groups should be user but the groups command shows user root If the passwd file is changed like so: root:x:0:500:root:/root:/bin/sh then the output of groups is user other --- Tested on Debian Slink groups (GNU coreutils) 8.5 Copyright (C) 2010 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. Written by David MacKenzie and James Youngman. -- <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> <> Brynnen Owen( this space for rent )<> <> o...@illinois.edu ( )<> <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>