Hi/2.

Paul Eggert wrote:
> KO Myung-Hun wrote:
> 
>> +# Check if symbolic link is supported
>> +have_symlink_support=false
>> +rm -f symlink$$.file symlink$$
>> +if (echo >symlink$$.file) 2>/dev/null; then
>> +  if ln -s symlink$$.file symlink$$ 2>/dev/null; then
>> +    have_symlink_support=true
>> +  fi
>> +fi
>> +rm -f symlink$$.file symlink$$
> 
> There's no need to use the echo; just use ln -s (the target need not
> exist).
> 
> Also, this test should be done dynamically, when the actual ln -s is
> run, not at the start of the run.  That is because 'ln -s' might succeed
> on some file systems but not on others.  It's OK to output a warning for
> the first ln -s that
> is replaced by a cp, but I wouldn't warn for each one.
> 

How about this ?

-- 
KO Myung-Hun

Using Mozilla SeaMonkey 2.7.2
Under OS/2 Warp 4 for Korean with FixPak #15
In VirtualBox v4.1.32 on Intel Core i7-3615QM 2.30GHz with 8GB RAM

Korean OS/2 User Community : http://www.ecomstation.co.kr

From a2eb734fb2a28475a65c0d5d630d9281129d7f58 Mon Sep 17 00:00:00 2001
From: KO Myung-Hun <k...@chollian.net>
Date: Wed, 1 May 2013 13:39:22 +0900
Subject: [PATCH] gnulib-tool: fall back into copy if symbolic link is not
 supported

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 | 28 ++++++++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)

diff --git a/gnulib-tool b/gnulib-tool
index 303df53..b746341 100755
--- a/gnulib-tool
+++ b/gnulib-tool
@@ -691,23 +691,43 @@ 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
+
+    cp -p "$1" "$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
       ;;
-- 
1.9.5

Reply via email to