Sudo of pain

Krevinek

Evil PPC Tweaker
I am glad I kept my OS 9 partition... well, I had to since I am running OS X unsupported. Anyways, NEVER type the following command: 'sudo mv (some item) /*' into the terminal. I managed to completely foobar my main partition, and even under the terminal it was impossible to move it back. The reason? mv/sudo/ls would segfault... not fun.

The solution was to boot into OS 9, unhide the private folder, and move all the folders buried in the /private/var folder back where they were supposed to go. The good news is that this accident made OS 9 rebuild my desktop and a bunch of other files on my main partition giving me a cleaner slate. This was a close one, because I am not in the mood to spend 2 hrs trying to get 10.1 to re-install again.
 
shouldnt have worked, since you have no target listed.
not that I am going to try to prove it otherwise.

Post

and it is fubar in your context....

F# Up Beyone All Recognition.

whereas foobar is what the first Voice recognition software
thought fubar was. Now is a common variable.
 
wow, that was a bad no-no mv.

what it did is that it expanded into

mv < some-item > /dir1 /dir2 /you-get-the-idea /var

and moved everything into /var; everything included your shared libraries, as well.

Reinstall.

Never, ever have a wildcard for the last argument of mv again. Especially not as root :)
 
Well, I managed to unmangle my mistake from OS 9 and everything is working (although EV Nova had its icon stripped, but the rest is intact).

Definitely a bad no-no and wasn't what I was trying to type at all.
 
Originally posted by Krevinek
Well, I managed to unmangle my mistake from OS 9 and everything is working (although EV Nova had its icon stripped, but the rest is intact).

Definitely a bad no-no and wasn't what I was trying to type at all.

Ah, an emergency bootable system (on a separate partition) Useful :)

Seriously, anyone knows how to make a bootable CD with OS X shell on it? Exactly for this kind of emergency work.
 
That is a tough one since the current version of MacOS X forces the swapfile onto the boot partition which would be locked in the case of a CD. I dunno, but the install CD may be slightly tweaked, but if you could fit an OS X Install onto a 700MB partition, then you could probably make a 'repair' CD yourself.
 
is possible by commenting out the line of /etc/rc which starts swap "process". Hopefully, you have enough RAM...
 
Howdy,

Just a little bit of unix clarification typing sudo mv /* would have worked fine for hozing your system. One of the ugly things in unix is that globbing (the process of expanding * et al) happens inthe shell so mv never sees the *'s. You can get a quick idea of what a commad expands into by typing echo infornt of it. On my box executing the above move would have expanded to

Code:
sudo mv Applications Applications (Mac OS 9) Cleanup At Startup \
 Dangerous Desktop DB Desktop DF Desktop Folder Developer Documents \
 Library MCL Microsoft Office X Network Shutdown Check System System \
 Folder TheVolumeSettingsFolder Trash Users Volumes automount bin cores \
 dev etc mach mach.sym mach_kernel private sbin sw tmp usr var

One would hope that the embedded spaces would be handled correctly and then everything goes to /var. There are a hole host of Stupid Unix Tricks based on this and things like it using files named for program argments

Code:
Welcome to Darwin!
[omppu:~] eric% mkdir stupid
[omppu:~] eric% cd stupid
[omppu:~/stupid] eric% touch foo
[omppu:~/stupid] eric% touch bar
[omppu:~/stupid] eric% mkdir baz
[omppu:~/stupid] eric% touch -- -rf [COLOR=red] #<- nasty trick[/COLOR]
[omppu:~/stupid] eric% touch baz/quux
[omppu:~/stupid] eric% touch baz/cure-for-cancer.text
[omppu:~/stupid] eric% ls  -lR
total 0
-rw-r--r--  1 eric  staff   0 Apr 10 12:57 -rf
-rw-r--r--  1 eric  staff   0 Apr 10 12:55 bar
drwxr-xr-x  4 eric  staff  92 Apr 10 12:58 baz
-rw-r--r--  1 eric  staff   0 Apr 10 12:54 foo

./baz:
total 0
-rw-r--r--  1 eric  staff  0 Apr 10 12:58 cure-for-cancer.text
-rw-r--r--  1 eric  staff  0 Apr 10 12:57 quux
[omppu:~/stupid] eric% rm *
[COLOR=red]# This was a bad idea cause it is all gone now[/COLOR]
[omppu:~/stupid] eric% ls -lR
total 0
-rw-r--r--  1 eric  staff  0 Apr 10 12:57 -rf
[omppu:~/stupid] eric% rm -- -rf [COLOR=red] #<- This gets rid of the -rf file[/COLOR]

Have fun,
-Eric
 
No, the embedded spaces do not get handled correctly, and so not everything goes to /var. But the System and Library sure do; and so does the kernel and the sbin and the whole plethora of other unixy thingies, some of which are unix symlinks and difficult to re-create correctly under OS9.

Fortunately, most resource forked files reside in directories with spaces on them, so that they tend not to get picked up.

BTW, shell globbing is a GoodThing(TM); it is just that whitespace in filenames is a VeryBadThingIndeed(TM), at least in unix. shell globbing is good, because it behaves the same and has the same quirks all over the place, and does not depend on program to program (DOS globbing, if available, from within a command; everyone globbed differently).
 
It is odd that the spaces weren't handled correctly, they worked fine on my end for a simple glob
Code:
[omppu:~/stupid] eric% ls
[omppu:~/stupid] eric% touch "foo bar"
[omppu:~/stupid] eric% touch quux
[omppu:~/stupid] eric% mkdir zot
[omppu:~/stupid] eric% ls -l
total 0
-rw-r--r--  1 eric  staff   0 Apr 12 23:46 foo bar
-rw-r--r--  1 eric  staff   0 Apr 12 23:46 quux
drwxr-xr-x  2 eric  staff  24 Apr 12 23:46 zot
[omppu:~/stupid] eric% sudo mv *
Password:
[omppu:~/stupid] eric% ls
zot
[omppu:~/stupid] eric% ls -lR
total 0
drwxr-xr-x  4 eric  staff  92 Apr 12 23:47 zot

./zot:
total 0
-rw-r--r--  1 eric  staff  0 Apr 12 23:46 foo bar
-rw-r--r--  1 eric  staff  0 Apr 12 23:46 quux
[omppu:~/stupid] eric%
Something else may well have broken the mv but in this case things should have worked. Now if one was storing the list of files to munch in a shell variable or piping the list of files from one process to another (like running a find and piping the results through xargs) all bets are off.

-Eric
 
Yes, it worked here as well. Odd.

OTOH, I am usually running these out of

for i in *

which would have to break with standard setting of IFS (bourne style shell)
 
Back
Top