Add -f flags to rm and mv

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Add -f flags to rm and mv

Ray Lai
Allows me to alias rm='rm -i' and make update-patches.  While I'm
here, add -f to other mv and rm commands.

Okay?

-Ray-

Index: build/update-patches
===================================================================
RCS file: /cvs/ports/infrastructure/build/update-patches,v
retrieving revision 1.15
diff -u -r1.15 update-patches
--- build/update-patches 3 Feb 2007 17:08:13 -0000 1.15
+++ build/update-patches 3 May 2007 18:08:30 -0000
@@ -62,11 +62,11 @@
  -I "^--- `echo $file$PATCHORIG | sed 's/[.+]/\\\\&/g'` " \
  -I "^\+\+\+ `echo $file | sed 's/[.+]/\\\\&/g'` " $i $i.new 1>&2
  then
-    rm $i.new
+    rm -f $i.new
  else
     echo 1>&2 "Patch $i for $file updated"
-    mv $i $i$PATCHORIG
-    mv $i.new $i
+    mv -f $i $i$PATCHORIG
+    mv -f $i.new $i
     edit="$edit $i"
  fi
  continue 2
Index: mk/bsd.port.mk
===================================================================
RCS file: /cvs/ports/infrastructure/mk/bsd.port.mk,v
retrieving revision 1.891
diff -u -r1.891 bsd.port.mk
--- mk/bsd.port.mk 8 Apr 2007 11:26:39 -0000 1.891
+++ mk/bsd.port.mk 3 May 2007 18:08:31 -0000
@@ -1763,7 +1763,7 @@
 
 _refetch:
 .  for file cipher value in ${_PROBLEMS}
- @rm ${DISTDIR}/${file}
+ @rm -f ${DISTDIR}/${file}
  @cd ${.CURDIR} && exec ${MAKE} ${DISTDIR}/${file} \
  MASTER_SITE_OVERRIDE="ftp://ftp.openbsd.org/pub/OpenBSD/distfiles/${cipher}/${value}/"
 .  endfor
@@ -2454,13 +2454,13 @@
 
 readme:
  @tmpdir=`mktemp -d ${TMPDIR}/readme.XXXXXX`; \
- trap 'rm -r $$tmpdir' 0 1 2 3 13 15; \
+ trap 'rm -rf $$tmpdir' 0 1 2 3 13 15; \
  cd ${.CURDIR} && ${MAKE} TMPDIR=$$tmpdir README_NAME=${README_NAME} \
  ${READMES_TOP}/${PKGPATH}/${FULLPKGNAME${SUBPACKAGE}}.html
 
 readmes:
  @tmpdir=`mktemp -d ${TMPDIR}/readme.XXXXXX`; \
- trap 'rm -r $$tmpdir' 0 1 2 3 13 15; \
+ trap 'rm -rf $$tmpdir' 0 1 2 3 13 15; \
  cd ${.CURDIR} && ${MAKE} TMPDIR=$$tmpdir README_NAME=${README_NAME} \
  ${_READMES}
 
@@ -2806,8 +2806,8 @@
 .for _CAT in ${CATEGORIES}
  @linkname=${PORTSDIR}/${_CAT}/`basename ${.CURDIR}`; \
  if [ -L $$linkname ]; then \
- echo "rm $$linkname"; \
- rm $$linkname; \
+ echo "rm -f $$linkname"; \
+ rm -f $$linkname; \
  if rmdir ${PORTSDIR}/${_CAT} 2>/dev/null; then \
  echo "rmdir ${PORTSDIR}/${_CAT}"; \
     fi; \
Index: mk/bsd.port.subdir.mk
===================================================================
RCS file: /cvs/ports/infrastructure/mk/bsd.port.subdir.mk,v
retrieving revision 1.83
diff -u -r1.83 bsd.port.subdir.mk
--- mk/bsd.port.subdir.mk 7 Apr 2007 09:55:13 -0000 1.83
+++ mk/bsd.port.subdir.mk 3 May 2007 18:08:31 -0000
@@ -155,7 +155,7 @@
 readmes:
  @DESCRIBE_TARGET=Yes; export DESCRIBE_TARGET; ${_subdir_fragment}
  @tmpdir=`mktemp -d ${TMPDIR}/readme.XXXXXX`; \
- trap 'rm -r $$tmpdir' 0 1 2 3 13 15; \
+ trap 'rm -rf $$tmpdir' 0 1 2 3 13 15; \
  cd ${.CURDIR} && ${MAKE} TMPDIR=$$tmpdir \
  ${READMES_TOP}/${PKGPATH}/README.html
 
@@ -177,7 +177,7 @@
  -e '/%%DESCR%%/r${.CURDIR}/pkg/DESCR' -e '//d' \
  -e '/%%SUBDIR%%/r${TMPDIR}/subdirs' -e '//d' \
  ${README} > $@
- @rm ${TMPDIR}/subdirs
+ @rm -f ${TMPDIR}/subdirs
 
 .PHONY: all fetch package fake extract configure \
  build describe distclean deinstall install update \

Reply | Threaded
Open this post in threaded view
|

Re: Add -f flags to rm and mv

Christian Weisgerber
Ray Lai <[hidden email]> wrote:

> Allows me to alias rm='rm -i' and make update-patches.  While I'm
> here, add -f to other mv and rm commands.
>
> Okay?

No.  Something is very wrong here.  Why do your interactive shell
aliases propagate to random shells?

--
Christian "naddy" Weisgerber                          [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Add -f flags to rm and mv

Ray Lai
In reply to this post by Ray Lai
> Ray Lai <[hidden email]> wrote:
> > Allows me to alias rm='rm -i' and make update-patches.  While I'm
> > here, add -f to other mv and rm commands.
> >
> > Okay?
>
> No.  Something is very wrong here.  Why do your interactive shell
> aliases propagate to random shells?

I export ENV=~/.profile

Reply | Threaded
Open this post in threaded view
|

Re: Add -f flags to rm and mv

Tobias Ulmer
On Mon, May 14, 2007 at 02:21:04PM -0400, Ray Lai wrote:

> > Ray Lai <[hidden email]> wrote:
> > > Allows me to alias rm='rm -i' and make update-patches.  While I'm
> > > here, add -f to other mv and rm commands.
> > >
> > > Okay?
> >
> > No.  Something is very wrong here.  Why do your interactive shell
> > aliases propagate to random shells?
>
> I export ENV=~/.profile
>
>


That leads to 'funny' results. Do something like this in your
.profile:

if [ -o interactive ]; then
:
fi

Tobias

Reply | Threaded
Open this post in threaded view
|

Re: Add -f flags to rm and mv

Craig Skinner
On Mon, May 14, 2007 at 09:30:48PM +0200, Tobias Ulmer wrote:

> > I export ENV=~/.profile
> >
> >
>
>
> That leads to 'funny' results. Do something like this in your
> .profile:
>
> if [ -o interactive ]; then
> :
> fi
>

$ cat /etc/profile
[ -o interactive ] && [ $SHELL = /bin/ksh ] && . /etc/ksh.kshrc


$ diff /etc/ksh.kshrc /etc/ksh.kshrc.orig | grep "^<" | fgrep -v \#
<       HOST=${HOST:-`hostname -s`}
<       PROMPT="<$USER@$HOST \W>$PS1S"
<               export TERM=xterm-color
<
<       alias rm='rm -i'
<       alias cp='cp -i'
<       if [ -x /usr/local/bin/colorls ]; then
<         alias ls='colorls -GF'
<       fi
<       alias ns='netstat -naf inet; netstat -naf inet6'
<       alias mutt='mutt -y'
<       alias vim='vim -u /etc/vimrc'
<       if [ -e /usr/local/bin/view ]; then
<         alias view='/usr/local/bin/view -u /etc/vimrc'
<       fi
<
<
<
<               alias df='df -h'
<               alias du='du -h'

Reply | Threaded
Open this post in threaded view
|

Re: Add -f flags to rm and mv

Christian Weisgerber
In reply to this post by Ray Lai
Ray Lai <[hidden email]> wrote:

> > No.  Something is very wrong here.  Why do your interactive shell
> > aliases propagate to random shells?
>
> I export ENV=~/.profile

You need to wrap the contents into something like

case $- in *i*)

...

;;
esac

to keep them away from non-interactive shells.  Alternatively, with ksh,
you can use this scary looking construct:

export ENVFILE=~/.kshrc
export ENV='${ENVFILE[(_=1)+(_$-=0)-_${-%%*i*}]}'

--
Christian "naddy" Weisgerber                          [hidden email]