[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v7 11/11] gnulib-tool: fall back into copy if symbolic link is no
From: |
KO Myung-Hun |
Subject: |
[PATCH v7 11/11] gnulib-tool: fall back into copy if symbolic link is not supported |
Date: |
Thu, 14 Jan 2016 11:23:51 +0900 |
And warn about it only once.
* gnulib-tool (first_fall_back_to_cp_warn): New. Indicator for only
once warning about falling back to cp -p.
(func_ln_s): New. Fall back into cp -p if ln -s fails. And warn about
this only once.
(func_ln): Replace ln -s with func_ln_s.
---
gnulib-tool | 35 +++++++++++++++++++++++++++++++----
1 file changed, 31 insertions(+), 4 deletions(-)
diff --git a/gnulib-tool b/gnulib-tool
index 34676f9..2c7d9d3 100755
--- a/gnulib-tool
+++ b/gnulib-tool
@@ -767,23 +767,50 @@ func_relconcat ()
done
}
+first_fall_back_to_cp_warn=true
+
+# func_ln_s SRC DEST
+# Like ln -s, except that cp -p is used if ln -s fails.
+func_ln_s ()
+{
+ if ln -s "$1" "$2" 2>/dev/null; then
+ :
+ else
+ if $first_fall_back_to_cp_warn; then
+ echo "gnulib-tool: symbolic link is not supported on this system." 1>&2
+ echo "Copy will be performed instead." 1>&2
+
+ first_fall_back_to_cp_warn=false
+ fi
+
+ case "$1" in
+ /* | ?:*) # SRC is absolute.
+ cp_src="$1" ;;
+ *) # SRC is relative to the directory of DEST.
+ cp_src="`echo "$2" | sed -e 's,\(^.*\)/[^/]*$,\1,'`/$1" ;;
+ esac
+
+ cp -p "$cp_src" "$2"
+ fi
+}
+
# func_ln SRC DEST
-# Like ln -s, except that SRC is given relative to the current directory (or
+# Like func_ln_s, except that SRC is given relative to the current directory
(or
# absolute), not given relative to the directory of DEST.
func_ln ()
{
case "$1" in
/* | ?:*)
- ln -s "$1" "$2" ;;
+ func_ln_s "$1" "$2" ;;
*) # SRC is relative.
case "$2" in
/* | ?:*)
- ln -s "`pwd`/$1" "$2" ;;
+ func_ln_s "`pwd`/$1" "$2" ;;
*) # DEST is relative too.
ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
test -n "$ln_destdir" || ln_destdir="."
func_relativize "$ln_destdir" "$1"
- ln -s "$reldir" "$2"
+ func_ln_s "$reldir" "$2"
;;
esac
;;
--
2.7.0
- Re: [PATCH v7 08/11] openat_proc_name: port to OS/2 kLIBC, (continued)
[PATCH v7 07/11] dup, dup2, fcntl: support a directory fd on OS/2 kLIBC, KO Myung-Hun, 2016/01/13
[PATCH v7 10/11] utimes: detect utimes() correctly on OS/2 kLIBC, KO Myung-Hun, 2016/01/13
[PATCH v7 09/11] opendir, closedir, dirfd, fdopendir: port to OS/2 kLIBC, KO Myung-Hun, 2016/01/13
[PATCH v7 11/11] gnulib-tool: fall back into copy if symbolic link is not supported,
KO Myung-Hun <=
- Re: [PATCH v7 11/11] gnulib-tool: fall back into copy if symbolic link is not supported, Paul Eggert, 2016/01/14
- Re: [PATCH v7 11/11] gnulib-tool: fall back into copy if symbolic link is not supported, KO Myung-Hun, 2016/01/14
- Re: [PATCH v7 11/11] gnulib-tool: fall back into copy if symbolic link is not supported, Paul Eggert, 2016/01/15
- Re: [PATCH v7 11/11] gnulib-tool: fall back into copy if symbolic link is not supported, KO Myung-Hun, 2016/01/15
- Re: [PATCH v7 11/11] gnulib-tool: fall back into copy if symbolic link is not supported, Paul Eggert, 2016/01/24
- Re: [PATCH v7 11/11] gnulib-tool: fall back into copy if symbolic link is not supported, KO Myung-Hun, 2016/01/24
- Re: [PATCH v7 11/11] gnulib-tool: fall back into copy if symbolic link is not supported, Paul Eggert, 2016/01/24
- Re: [PATCH v7 11/11] gnulib-tool: fall back into copy if symbolic link is not supported, KO Myung-Hun, 2016/01/24
Re: [PATCH v7 00/11] OS/2 patches, Paul Eggert, 2016/01/14