[zfs-auto-snapshot] ksh93 solution
Stuart Anderson
anderson at ligo.caltech.edu
Fri Jan 2 12:32:56 PST 2009
Carson,
I thought I would give this a try and learn a little hg at the same
time. However, the following does not appear to work after saving this
email to a text file. Is this the right hg command? Is there a URL or
an email attachment I can download to make sure my mail client is not
munging the patch?
Thanks.
$ hg import ~/Desktop/zfs-auto-snapshot-no-ksh93.txt
applying /Users/stuartanderson/Desktop/zfs-auto-snapshot-no-ksh93.txt
/usr/bin/patch: **** malformed patch at line 10: #
abort: patch command failed: exited with status 2
On Jan 2, 2009, at 3:33 AM, Carson Gaspar wrote:
> Here's a POSIX solution to the ksh93 only string replacement problem.
> Sadly ksh93 doesn't want to build on Solaris 10u6, so I can't do a
> performance comparison, but this should be fairly fast.
>
> carson:gandalf 0 SOL$ hg diff src/lib/svc/method/zfs-auto-snapshot
> diff -r 05a41ca81219 src/lib/svc/method/zfs-auto-snapshot
> --- a/src/lib/svc/method/zfs-auto-snapshot Sun Dec 14 18:30:29
> 2008
> +0000
> +++ b/src/lib/svc/method/zfs-auto-snapshot Fri Jan 02 03:29:51
> 2009
> -0800
> @@ -1,4 +1,4 @@
> -#!/usr/bin/ksh93
> +#!/usr/bin/ksh
>
> #
> # CDDL HEADER START
> @@ -761,6 +761,20 @@
>
> }
>
> +# avoid ksh93 only expression ${LIST//\/\//}
> +function stripstring {
> + typeset instr="$1"
> + typeset pat="$2"
> + typeset pre
> + typeset post
> + while true; do
> + pre=${instr%%$pat*}
> + post=${instr#*$pat}
> + if test "$post" == "$pre"; then break; fi
> + instr="${pre}${post}"
> + done
> + echo "$instr"
> +}
>
> # Given a sorted list of filesystems of which we can take recursive
> snapshots,
> # determine whether any of the listed filesystems are redundant
> @@ -801,7 +815,7 @@
> fi
> done
> # remove the // separators from the string
> - echo ${LIST//\/\//}
> + stripstring "$LIST" '//'
> }
>
> function can_recursive_snapshot {
> _______________________________________________
> zfs-auto-snapshot mailing list
> zfs-auto-snapshot at opensolaris.org
> http://mail.opensolaris.org/mailman/listinfo/zfs-auto-snapshot
--
Stuart Anderson anderson at ligo.caltech.edu
http://www.ligo.caltech.edu/~anderson
More information about the zfs-auto-snapshot
mailing list