From: SF/projects/mingw n. l. <min...@li...> - 2011-10-14 01:30:56
|
Bugs item #3415129, was opened at 2011-09-28 17:34 Message generated for change (Comment added) made by cstrauss You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=102435&aid=3415129&group_id=2435 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: MSYS Group: IINR - Include In Next Release Status: Closed Resolution: Fixed Priority: 5 Private: No Submitted By: Earnie Boyd (earnie) Assigned to: Cesar Strauss (cstrauss) Summary: Files and directories beginning with ~ Initial Comment: If a file or directory is named ~FOO then it is impossible to remove it and even more so dangerous to try. MSYS converts ~FOO to // instead so that using rm -rf ~FOO will in effect cause an rm -rf // to be issued. I'm using msys-core-1.0.17 ---------------------------------------------------------------------- >Comment By: Cesar Strauss (cstrauss) Date: 2011-10-13 22:30 Message: > What happens with the fixed runtime from CVS? cstrauss@home ~ $ echo ~foo ~foo cstrauss@home ~ $ sh -c "echo ~foo" ~foo ---------------------------------------------------------------------- Comment By: Fabian Greffrath (fabian_deb) Date: 2011-10-13 06:53 Message: Dear Cesar, with the current runtime the following happens: admin@durin ~ $ echo ~foo / admin@durin ~ $ sh -c "echo ~foo" /home/admin What happens with the fixed runtime from CVS? ---------------------------------------------------------------------- Comment By: Cesar Strauss (cstrauss) Date: 2011-10-12 12:21 Message: Fixed in CVS. Before: $ echo ~ /home/cstrauss $ echo ~cstrauss / $ echo ~foo / After: $ echo ~ /home/cstrauss $ echo ~cstrauss /home/cstrauss $ echo ~foo ~foo Regards, Cesar ---------------------------------------------------------------------- Comment By: Cesar Strauss (cstrauss) Date: 2011-10-08 20:07 Message: Thanks for the report. The problem is in the getpwnam implementation in MSYS. For names other than the current user name, it should return NULL, instead of an entry filled with default values. The next MSYS runtime release will have a fix. Regards, Cesar ---------------------------------------------------------------------- Comment By: Fabian Greffrath (fabian_deb) Date: 2011-10-05 07:48 Message: > #if defined (HAVE_GETPWNAM) || defined __MSYS__ This should read #if defined (HAVE_GETPWNAM) && !defined __MSYS__ ---------------------------------------------------------------------- Comment By: Fabian Greffrath (fabian_deb) Date: 2011-10-05 07:38 Message: Maybe bash should be compiled with -UHAVE_GETPWNAM. Else in lib/{tilde,readline}/tilde.c:390 getpwnam() is performed on the username part of the expanded string and then in line 414 "user_entry->pw_dir" is called to replace it with the user's home directory. Maybe in lib/{tilde,readline}/tilde.c:390 #if defined (HAVE_GETPWNAM) should get changed to #if defined (HAVE_GETPWNAM) || defined __MSYS__ as MSYS simply does not support the concept of per-user directories. ---------------------------------------------------------------------- Comment By: Keith Marshall (keithmarshall) Date: 2011-09-29 07:57 Message: You may wish to consider the comment I attached here: http://thread.gmane.org/gmane.comp.gnu.mingw.user/37674/focus=37677 Note that, in the example command offered, the shell would attempt to expand ~FOO as the home directory for user FOO, *before* handing it off to rm. Since MSYS doesn't associate users with specific home directories, (other than during execution of /etc/profile to initialise $HOME), tilde expansion should *always* fail gracefully, (except in the special case of a solitary tilde, which should and does expand to the value of $HOME), leaving the tilde expression unchanged; since it *is* changed there clearly is a bug. Just wanted to point out that it might lie within the bash.exe implementation, rather than in msys-core, (although it could equally well be in a service provided to bash by msys-1.0.dll). As an interim (untested) work-around, 'rm -rf ./~FOO', or even simply wrapping ~FOO in quotes, (either double or single), should circumvent the tilde expansion, so allowing you to safely remove the errant directory; c.f.: $ echo ~FOO / $ echo ./~FOO ./~FOO $ echo '~FOO' ~FOO $ echo "~FOO" ~FOO Also, notice this anomaly when running in a subshell: $ echo ~FOO /home/keith ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=102435&aid=3415129&group_id=2435 |