[Midnight Commander] #4559: Bug with nested dirs in u7z mkdir action

0 views
Skip to first unread message

Ticket System

unread,
Jul 9, 2024, 8:53:13 AM (8 days ago) Jul 9
to ponko...@protonmail.com, mc-...@googlegroups.com
#4559: Bug with nested dirs in u7z mkdir action
--------------------------------+------------------------------
Reporter: ponko | Type: defect
Status: new | Priority: major
Milestone: Future Releases | Component: mc-vfs
Version: master | Keywords:
Blocked By: | Blocking:
Branch state: no branch | Votes for changeset:
--------------------------------+------------------------------
Current

{{{
$P7ZIP a -w"$dir" "$1" "$dir"/"$2" ..
}}}

Should be

{{{
$P7ZIP a "$1" "$dir/${2%%/*}" ..
}}}


== Case1 ==

- open some 7z archive
- press F7
- type a/b/c, press enter
- restart mc
- open the archive
- expected: "a", "a/b", "a/b/c" dirs
- actual: "c" dir

== Case2 ==

- left panel: open some 7z archive
- right panel: create x/y/z path, copy x to the left
- restart mc
- open the archive
- expected: "x", "x/y", "x/y/z" dirs
- actual: "x", "y", "z" dirs

I could guess what one meant putting -w there, and it was completely wrong
idea. -w option:

''Sets the working directory for the temporary base archive. By default,
7-Zip builds a new base archive file in the same directory as the old base
archive file. By specifying this switch, you can set the working directory
where the temporary base archive file will be built. After the temporary
base archive file is built, it is copied over the original archive; then,
the temporary file is deleted.''

By default, 7z only looks at the last part of the path. E.g. if we say "7z
a 1.7z a/b/c", it adds the "c" dir. There is the "-spf" option (idk since
which version) to make it use the whole path provided, but it means more
code in our case:

cd "$dir"
$P7ZIP a -spf "$1" "$2" ..
cd -

The one-liner `$P7ZIP a "$1" "$dir/${2%%/*}" ..` looks better.

--
Ticket URL: <http://www.midnight-commander.org/ticket/4559>
Midnight Commander <https://midnight-commander.org>
Midnight Development Center

Reply all
Reply to author
Forward
0 new messages