Art Alexion on 1 Feb 2006 18:59:14 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Interactive rm


Andrew Libby wrote:

>Michael C. Toren wrote:
>
>  
>
>>Art Alexion wrote:
>> 
>>
>>    
>>
>>>>How can I restore rm's default behavior so that "rm *" requires
>>>>confirmation, but "rm specified_file" does not?
>>>>     
>>>>
>>>>        
>>>>
>>gyoza@comcast.net wrote:
>> 
>>
>>    
>>
>>>Create an alias.
>>>   
>>>
>>>      
>>>
>>morgan wrote:
>> 
>>
>>    
>>
>>>If you're using bash you would create an alias:
>>>
>>>alias rm="rm -i"
>>>   
>>>
>>>      
>>>
>>Creating an alias won't solve Art's problem, which is using the "-i" flag
>>when rm is passed multiple files, but not using "-i" when only a single
>>file is specified -- rather, an alias will use "-i" in every case.  One
>>possible solution is to create a bash function which determines how many
>>arguments it was passed:
>>
>>	rm()
>>	{
>>	    if [ $# -lt 2 ]
>>	    then /bin/rm $*
>>	    else /bin/rm -i $*
>>	    fi
>>	}
>>
>>This works for the majority of cases:
>>
>>	[mct@ellesmere ~]$ touch foo bar baz
>>	[mct@ellesmere ~]$ rm foo
>>	[mct@ellesmere ~]$ rm bar baz
>>	/bin/rm: remove `bar'? y
>>	/bin/rm: remove `baz'? y
>> 
>>
>>    
>>
>
>This is a very cool solution!  A question I have is what art intended for
>the following cases:
>
>rm file1 file2
>rm file*
>rm file.???
>
>My bet is that the first case, he'd not want interactive rm, but in the
>second and third
>he would.   Am I correct in my supposition that wild cards are expanded
>prior to
>invocation of the shell function?  That would make this desire
>impossible, wouldn't it?
>Anyone have any idea how we might expand this solution to accommodate
>non-wild card
>multi parameter invocations or rm?
>  
>
Actually if I recall correctly, in RH 6.2 none of the examples you gave
were interactive; only rm *

I could live with all three examples being interactive, but could I
override it with 'rm -f *'?


-- 

_______________________________________
Art Alexion
Arthur S. Alexion LLC

PGP fingerprint: 52A4 B10C AA73 096F A661  92D2 3B65 8EAC ACC5 BA7A
The attachment -- signature.asc -- is my electronic signature; no need for alarm.
Info @ http://mysite.verizon.net/art.alexion/encryption/signature.asc.what.html

Key for signed PDFs available at
http://mysite.verizon.net/art.alexion/encryption/ArthurSAlexion.p7c
The validation string is TTJY-ZILJ-BJJG.
________________________________________

Attachment: signature.asc
Description: OpenPGP digital signature

___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug