Ticket #1967 (closed defect: fixed)

Opened 14 years ago

Last modified 14 years ago

Incorrect create subdirectory to extract archive

Reported by: pavlinux Owned by: andrew_b
Priority: major Milestone: 4.7.1
Component: mc-core Version: master
Keywords: Cc: ossi, Graham
Blocked By: Blocking:
Branch state: Votes for changeset: commuted-master committed-stable

Description

Archive files containing spaces in their name, extracted
in a pre-created directory.
But the directory is not created correctly, and is divided
into parts.

ex.

# ls
Some File.tar.bz2

# tar -xf Some\ File.tar.bz2
# ls -F1
Some File.tar.bz2
Some File/ 

# mc 
<F2> 
" z - Extract compressed file to subdirectory" 

<F10>

# ls -F1
File/
Some/
Some File.tar.bz2

# ls -RF1
.:
File/
Some/
Some File.tar.bz2

./File:

./Some:
back-matter.pdf
front-matter.pdf
springer_url.txt

:)

Attachments

mc.menu.diff (2.4 KB) - added by pavlinux 14 years ago.
Quote disrectory names

Change History

Changed 14 years ago by pavlinux

Quote disrectory names

comment:2 follow-up: ↓ 3 Changed 14 years ago by Graham

I'm not sure if I should create a new ticket or add to this one, but I think this might be based on the problem mentioned above. If it's felt that this needs a new ticket, I'll happily create one.

If I create an archive with a space within its name (new directory.tar.bz2), then hit F2 and "x Extract the contents of a compressed tar file", nothing appears to happen. If I then access the shell (Ctrl-o), I find the following:

$ /bin/sh /tmp/mc-xxxx/mcusrc8M3ba
bunzip2: Can't open input file new\: No such file or directory.
bunzip2: Can't open input file directory.tar.bz2: No such file or directory.
tar: This does not look like a tar archive
tar: Error exit delayed from previous errors

Doing the above with an archive without a space works as expected. Also, if I enter the archive with a space within its file name using mc (select "new directory.tar.bz2" and hit enter), then I can navigate within the archive and also copy its contents elsewhere without a problem.

I thought I'd bring this up here, because it seems like a similar problem.

comment:3 in reply to: ↑ 2 Changed 14 years ago by pavlinux

Replying to Graham:

I'm not sure if I should create a new ticket or add to this one, but I think this might be based on the problem mentioned above. If it's felt that this needs a new ticket, I'll happily create one.

If I create an archive with a space within its name (new directory.tar.bz2), then hit F2 and "x Extract the contents of a compressed tar file", nothing appears to happen. If I then access the shell (Ctrl-o), I find the following:

$ /bin/sh /tmp/mc-xxxx/mcusrc8M3ba
bunzip2: Can't open input file new\: No such file or directory.
bunzip2: Can't open input file directory.tar.bz2: No such file or directory.
tar: This does not look like a tar archive
tar: Error exit delayed from previous errors

Doing the above with an archive without a space works as expected. Also, if I enter the archive with a space within its file name using mc (select "new directory.tar.bz2" and hit enter), then I can navigate within the archive and also copy its contents elsewhere without a problem.

I thought I'd bring this up here, because it seems like a similar problem.

See patch.

Problem in mkdir and cd command

Try in shell

# mkdir Some Directory
# mkdir "Some Directory"
# cd Some Directory
# cd "Some Directory"

is simple... :)

comment:4 Changed 14 years ago by andrew_b

  • Status changed from assigned to accepted
  • Owner changed from pavlinux to andrew_b

comment:5 Changed 14 years ago by andrew_b

  • severity changed from no branch to on review

Created 1967_menu_quoting branch. Parent branch: master.
changeset:2d6af30779ce797f6a91f98c42ab3c6a8a24d377

comment:6 Changed 14 years ago by angel_il

  • Votes for changeset set to angel_il

comment:7 Changed 14 years ago by slavazanko

  • Votes for changeset changed from angel_il to angel_il slavazanko
  • severity changed from on review to approved

comment:8 Changed 14 years ago by andrew_b

  • Votes for changeset changed from angel_il slavazanko to commited-master
  • severity changed from approved to merged

comment:9 Changed 14 years ago by andrew_b

  • Status changed from accepted to testing
  • Resolution set to fixed

comment:10 Changed 14 years ago by slavazanko

  • Status changed from testing to closed
  • Votes for changeset changed from commited-master to commited-master commited-stable

comment:11 Changed 14 years ago by andrew_b

  • Status changed from closed to reopened
  • Resolution fixed deleted

Need remove some extra unneeded quotes.

comment:12 follow-up: ↓ 19 Changed 14 years ago by andrew_b

  • Votes for changeset commited-master commited-stable deleted
  • Version changed from version not selected to master
  • severity changed from merged to on review

Created branch 1967_menu_extra_quoting. Parent branch is master.
changeset:b7525db2d5deb6d173bebebfb25e1cdb739d83d0

Please review again.

comment:13 follow-up: ↓ 14 Changed 14 years ago by slavazanko

Previous two comments in Russian deleted. Reason: language of tickets is English.

Translate your messages into English and repeat posting of comments, please.

pavlinux, لغات أخرى ليتم احترام
αλλά η επίσημη αγγλική-μόνο

comment:14 in reply to: ↑ 13 Changed 14 years ago by pavlinux

Replying to slavazanko:

Previous two comments in Russian deleted. Reason: language of tickets is English.
Translate your messages into English and repeat posting of comments, please.

pavlinux, لغات أخرى ليتم احترام

Алах аккбар :)

Funny! Quotes prevented you ... smart zhzhut ...

# mkdir 'TEst \ n Dir \ r X'
# echo> 'TEst \ n file'
# ls-la

drwxr-xr-x 2 root root 40 Feb 1 17:02 TEst \ n Dir \ r X
-rw-r--r-- 1 root root 0 1 Feb17:01 TEst \ n file

# echo TEst \ n file

TEstn file

moreover, if the directory "TEst \ n Dir \ r X" to create an archive, we obtain
TEstn Dirr X. Tar.bz2

comment:15 Changed 14 years ago by pavlinux

Sorry, defect formating...

# mkdir 'TEst\n Dir\r X'
# echo> 'TEst\n file'
# ls-la

drwxr-xr-x 2 root root 40 Feb 1 17:02 TEst\n Dir\r X
-rw-r--r-- 1 root root 0 1 Feb17:01 TEst\n file

# echo TEst\n file

TEstn file

moreover, if the directory "TEst\n Dir\r X" to create an archive, we obtain
TEstn Dirr X. Tar.bz2

comment:16 Changed 14 years ago by slavazanko

  • Cc ossi added

comment:17 follow-up: ↓ 18 Changed 14 years ago by pavlinux

PATCH

comment:18 in reply to: ↑ 17 Changed 14 years ago by pavlinux

Replying to pavlinux:

PATCH

diff --git a/misc/mc.menu b/misc/mc.menu     
index cf35412..2a82641 100644
--- a/misc/mc.menu
+++ b/misc/mc.menu
@@ -28,7 +28,7 @@ shell_patterns=0

 = t d
 3       Compress the current subdirectory (tar.gz)
-       Pwd=`basename %d /`
+       Pwd=`pwd`
        echo -n "Name of the compressed file (without extension) [$Pwd]: "
        read tar
         if [ "$tar"x = x ]; then tar="$Pwd"; fi
@@ -37,7 +37,7 @@ shell_patterns=0
        echo "../$tar.tar.gz created."

 4       Compress the current subdirectory (tar.bz2)
-       Pwd=`basename %d /`
+       Pwd=`pwd`
        echo -n "Name of the compressed file (without extension) [$Pwd]: "
        read tar
         if [ "$tar"x = x ]; then tar="$Pwd"; fi
@@ -46,7 +46,7 @@ shell_patterns=0
        echo "../$tar.tar.bz2 created."

 5       Compress the current subdirectory (tar.p7)
-       Pwd=`basename %d /`
+       Pwd=`pwd`
        echo -n "Name of the compressed file (without extension) [$Pwd]: "
        read tar
         if [ "$tar"x = x ]; then tar="$Pwd"; fi
@@ -55,7 +55,7 @@ shell_patterns=0
        echo "../$tar.tar.7z created."

 6       Compress the current subdirectory (tar.lzma)
-       Pwd=`basename %d /`
+       Pwd=`pwd`
        echo -n "Name of the compressed file (without extension) [$Pwd]: "
        read tar
         if [ "$tar"x = x ]; then tar="$Pwd"; fi
@@ -64,7 +64,7 @@ shell_patterns=0
        echo "../$tar.tar.lzma created."

 7       Compress the current subdirectory (tar.lz)
-       Pwd=`basename %d /`
+       Pwd=`pwd`
        echo -n "Name of the compressed file (without extension) [$Pwd]: "
        read tar
         if [ "$tar"x = x ]; then tar="$Pwd"; fi
@@ -73,7 +73,7 @@ shell_patterns=0
        echo "../$tar.tar.lz created."

comment:19 in reply to: ↑ 12 ; follow-up: ↓ 20 Changed 14 years ago by ossi

Replying to andrew_b:

changeset:b7525db2d5deb6d173bebebfb25e1cdb739d83d0

i wouldn't remove the quotes from the echos which contain no expandos - for one, quoted strings are more legible (unlike paths and such). second, if they contain proper variables (i.e., $var, not %expando) with multiple subsequent spaces (which is rather unlikely, but still), the missing quotes would falsify the output.
what do do about commands which contain both variables and expandos? if glib isn't smart enough to detect the already present quotes and not add additional ones then, then "hybrid quoting" needs to be used: echo "this is $v/"%d" blah". please verify what glib can do - kde's kmacroexpander would be smart enough to deal with that as long as no command indirections ("sh -c 'nested command') are used, so maybe glib is as well.

comment:20 in reply to: ↑ 19 ; follow-up: ↓ 22 Changed 14 years ago by pavlinux

Replying to ossi:

Replying to andrew_b:

Fix, creation archives from dirs contains "\" in name

diff --git a/misc/mc.menu b/misc/mc.menu             
index cf35412..9205d17 100644                        
--- a/misc/mc.menu                                   
+++ b/misc/mc.menu                                   
@@ -28,8 +28,8 @@ shell_patterns=0                   
                                                     
 = t d                                               
 3       Compress the current subdirectory (tar.gz)  
-       Pwd=`basename %d /`
-       echo -n "Name of the compressed file (without extension) [$Pwd]: "
+       Pwd=`basename "$(pwd)"`
+       echo -n "Name of the compressed file (without extension) [$Pwd]:"
        read tar
         if [ "$tar"x = x ]; then tar="$Pwd"; fi
        cd .. && \
@@ -37,7 +37,7 @@ shell_patterns=0
        echo "../$tar.tar.gz created."

 4       Compress the current subdirectory (tar.bz2)
-       Pwd=`basename %d /`
+       Pwd=`basename "$(pwd)"`
        echo -n "Name of the compressed file (without extension) [$Pwd]: "
        read tar
         if [ "$tar"x = x ]; then tar="$Pwd"; fi
@@ -46,7 +46,7 @@ shell_patterns=0
        echo "../$tar.tar.bz2 created."

 5       Compress the current subdirectory (tar.p7)
-       Pwd=`basename %d /`
+       Pwd=`basename "$(pwd)"`
        echo -n "Name of the compressed file (without extension) [$Pwd]: "
        read tar
         if [ "$tar"x = x ]; then tar="$Pwd"; fi
@@ -55,7 +55,7 @@ shell_patterns=0
        echo "../$tar.tar.7z created."

 6       Compress the current subdirectory (tar.lzma)
-       Pwd=`basename %d /`
+       Pwd=`basename "$(pwd)"`
        echo -n "Name of the compressed file (without extension) [$Pwd]: "
        read tar
         if [ "$tar"x = x ]; then tar="$Pwd"; fi
@@ -64,7 +64,7 @@ shell_patterns=0
        echo "../$tar.tar.lzma created."

 7       Compress the current subdirectory (tar.lz)
-       Pwd=`basename %d /`
+       Pwd=`basename "$(pwd)"`
        echo -n "Name of the compressed file (without extension) [$Pwd]: "
        read tar
         if [ "$tar"x = x ]; then tar="$Pwd"; fi
@@ -73,7 +73,7 @@ shell_patterns=0
        echo "../$tar.tar.lz created."

 8       Compress the current subdirectory (tar.xz)
-       Pwd=`basename %d /`
+       Pwd=`basename "$(pwd)"`
        echo -n "Name of the compressed file (without extension) [$Pwd]: "
        read tar
         if [ "$tar"x = x ]; then tar="$Pwd"; fi

comment:21 Changed 14 years ago by andrew_b

I decided to keep quotes of echo arguments.
Branch have been rebased. changeset:ba1a3c930f10cd2b241075a8cca24ac9b171cd44

comment:22 in reply to: ↑ 20 ; follow-up: ↓ 23 Changed 14 years ago by ossi

Replying to pavlinux:

  • Pwd=basename %d /

+ Pwd=basename "$(pwd)"

the $() syntax is posix, but unfortunately the standard solaris /bin/sh is not posix (at least it wasn't until relatively recently).
why are you trying to remove the expando? if nesting it into backticks causes problems (which is kinda expected, as backticks suck), then rewrite it as:
Pwd=%d
Pwd=basename "$Pwd" /

comment:23 in reply to: ↑ 22 ; follow-up: ↓ 24 Changed 14 years ago by pavlinux

Replying to ossi:

Replying to pavlinux:

  • Pwd=basename %d /

+ Pwd=basename "$(pwd)"

the $() syntax is posix, but unfortunately the standard solaris /bin/sh is not posix (at least it wasn't until relatively recently).
why are you trying to remove the expando? if nesting it into backticks causes problems (which is kinda expected, as backticks suck), then rewrite it as:
Pwd=%d
Pwd=basename "$Pwd" /

May be

Pwd=basename "$PWD"

$PWD variable exists in Solaris?
Or may not exist in Multics, or accident is not in the CP/M or VAX/VMS 4.0?
Then do not go. :)


http://www.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_05_03

comment:24 in reply to: ↑ 23 Changed 14 years ago by ossi

Replying to pavlinux:

Pwd=basename "$PWD"

$PWD variable exists in Solaris?

dunno.
but quotes inside backticks are a receipe for disaster.
for enhanced effect, try some complex nesting with three different shells - you'll get three different results (at least).

comment:26 Changed 14 years ago by pavlinux

SCREENSHOT from SunOS 5.10 aka Solaris 10

http://s42.radikal.ru/i096/1002/82/465b223ad40a.png

comment:27 Changed 14 years ago by angel_il

pavlinux, take it easy.

comment:28 Changed 14 years ago by angel_il

pavlinux wrote:
Put Solaris and make sure that everything works, and $(pwd) too, run csh, zsh, tcsh, ash, and check that everything is working there too .... [root@lhost: /tmp/TEST/TEst\n Dir\r X # pwd /tmp/TEST/TEst\n Dir\r X [root@lhost: /tmp/TEST/TEst\n Dir\r X # basename "$PWD" TEst\n Dir\r X [root@lhost:/tmp/TEST/TEst\n Dir\r X # zsh root@suse64:/tmp/TEST/TEst\n Dir\r X # basename "$PWD" TEst\n Dir\r X root@suse64:/tmp/TEST/TEst\n Dir\r X # csh suse64 TEST/TEst\n Dir\r X# basename "$PWD" TEst\n Dir\r X

comment:29 Changed 14 years ago by ossi

solaris 10 is rather recent by corporate standards. a lot of sysadmins still work with solars 9 or even 8, hpux and some other de-facto dead proprietary unixes.
but it's nice to see that solaris' opening up finally brought it into the 21st century. :)

comment:30 follow-up: ↓ 31 Changed 14 years ago by zaytsev

Since when HPUX and Solaris 9 are dead? Have to check file and computing servers :-( Hopefully they are all online.

comment:31 in reply to: ↑ 30 ; follow-up: ↓ 32 Changed 14 years ago by pavlinux

Replying to zaytsev:

Since when HPUX and Solaris 9 are dead?

In August 1991,...

comment:32 follow-up: ↓ 33 Changed 14 years ago by andrew_b

  • Blocking 2000 added

(In #2000) Replying to Graham:

Also, maybe this is related in some way to the fix in ticket #1967, where I mentioned a similar issue with the x option in F2, but which dealt with an archive with a space within its name. The error was a little different, but thought I'd mention it.

Yes. There are some overquoting in user menu were maken. Mea culpa. :-(

comment:31 follow-up: ↓ 32 Changed 14 years ago by Graham

changeset:ba1a3c930f10cd2b241075a8cca24ac9b171cd44 has fixed the F2 + x problem I mentioned in #2000 (I've applied that patch to mc.menu and mc.menu.sr found in 4.7.0.2, then compiled and installed), in that an archive with no spaces in its name is extracted fine, but archives with spaces within their name still don't seem to work (they do work with F2 + z, just not F2 + x). Below is what you see in the shell when you press ctrl-o after selecting an archive with a space within its name (blah bler.tar.bz2) and pressing F2 then selecting x:

$ /bin/sh /tmp/mc-xxxx/mcusrHXSpie
bunzip2: Can't open input file blah\: No such file or directory.
bunzip2: Can't open input file bler.tar.bz2: No such file or directory.
tar: This does not look like a tar archive
tar: Error exit delayed from previous errors

comment:32 in reply to: ↑ 31 ; follow-up: ↓ 33 Changed 14 years ago by andrew_b

  • Cc Graham added

Replying to Graham:

archives with spaces within their name still don't seem to work (they do work with F2 + z, just not F2 + x). Below is what you see in the shell when you press ctrl-o after selecting an archive with a space within its name (blah bler.tar.bz2) and pressing F2 then selecting x:

$ /bin/sh /tmp/mc-xxxx/mcusrHXSpie
bunzip2: Can't open input file blah\: No such file or directory.
bunzip2: Can't open input file bler.tar.bz2: No such file or directory.
tar: This does not look like a tar archive
tar: Error exit delayed from previous errors

Would you try changeset:687ba251a7ccd51cf9f2e2c49fc626e994445ec7?

comment:33 in reply to: ↑ 32 ; follow-ups: ↓ 34 ↓ 35 Changed 14 years ago by andrew_b

comment:34 in reply to: ↑ 33 Changed 14 years ago by Graham

Replying to andrew_b:

Oops, sorry...
changeset:631002a0d5101ac2b4c6eec484ffc76b0d3d847c

Yes, that seems to have fixed it.

Thanks. :)

comment:35 in reply to: ↑ 33 ; follow-up: ↓ 36 Changed 14 years ago by Graham

Replying to andrew_b:

Oops, sorry...
changeset:631002a0d5101ac2b4c6eec484ffc76b0d3d847c

Sorry, I'm back. ;) Just one really trivial thing: should there be two "f \.tar\.lz$"s on line 225 in mc.menu (line 187 in mc.menu.sr)?

comment:36 in reply to: ↑ 35 Changed 14 years ago by andrew_b

Replying to Graham:

Just one really trivial thing: should there be two "f \.tar\.lz$"s on line 225 in mc.menu (line 187 in mc.menu.sr)?

Of cause, no. Thanks for the attentiveness! :)

comment:37 Changed 14 years ago by slavazanko

  • Votes for changeset set to slavazanko

comment:38 Changed 14 years ago by angel_il

  • Votes for changeset changed from slavazanko to slavazanko angel_il
  • severity changed from on review to approved

comment:39 Changed 14 years ago by andrew_b

  • Status changed from reopened to closed
  • Votes for changeset changed from slavazanko angel_il to commuted-master commited-stable
  • Resolution set to fixed
  • severity changed from approved to merged
  • Blocking 2000 removed
Note: See TracTickets for help on using tickets.