1*7c478bd9Sstevel@tonic-gate#!/sbin/sh 2*7c478bd9Sstevel@tonic-gate# 3*7c478bd9Sstevel@tonic-gate# CDDL HEADER START 4*7c478bd9Sstevel@tonic-gate# 5*7c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the 6*7c478bd9Sstevel@tonic-gate# Common Development and Distribution License, Version 1.0 only 7*7c478bd9Sstevel@tonic-gate# (the "License"). You may not use this file except in compliance 8*7c478bd9Sstevel@tonic-gate# with the License. 9*7c478bd9Sstevel@tonic-gate# 10*7c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 11*7c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing. 12*7c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions 13*7c478bd9Sstevel@tonic-gate# and limitations under the License. 14*7c478bd9Sstevel@tonic-gate# 15*7c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each 16*7c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 17*7c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the 18*7c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying 19*7c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner] 20*7c478bd9Sstevel@tonic-gate# 21*7c478bd9Sstevel@tonic-gate# CDDL HEADER END 22*7c478bd9Sstevel@tonic-gate# 23*7c478bd9Sstevel@tonic-gate# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T 24*7c478bd9Sstevel@tonic-gate# All Rights Reserved 25*7c478bd9Sstevel@tonic-gate 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.3 */ 28*7c478bd9Sstevel@tonic-gate# This program changes all occurences of the SVR2 getopt invocation line 29*7c478bd9Sstevel@tonic-gate# to use the SVR3 version of getopt. 30*7c478bd9Sstevel@tonic-gate# Sedfunc is used to handle arguments with single quotes. 31*7c478bd9Sstevel@tonic-gate# If -b option is given, getoptcvt will create script that will usually work 32*7c478bd9Sstevel@tonic-gate# in releases previous to 3.0. 33*7c478bd9Sstevel@tonic-gatebflag= 34*7c478bd9Sstevel@tonic-gatewhile getopts b c 35*7c478bd9Sstevel@tonic-gatedo 36*7c478bd9Sstevel@tonic-gate case $c in 37*7c478bd9Sstevel@tonic-gate b) bflag=1;; 38*7c478bd9Sstevel@tonic-gate \?) echo "getoptcvt [-b] file" 39*7c478bd9Sstevel@tonic-gate exit 2;; 40*7c478bd9Sstevel@tonic-gate esac 41*7c478bd9Sstevel@tonic-gatedone 42*7c478bd9Sstevel@tonic-gateshift `expr $OPTIND - 1` 43*7c478bd9Sstevel@tonic-gateif [ "$bflag" = 1 ] 44*7c478bd9Sstevel@tonic-gatethen 45*7c478bd9Sstevel@tonic-gate ed <<'!' - $1 46*7c478bd9Sstevel@tonic-gate1,$s/set[ ][ ]*--[ ][ ]*`getopt[ ][ ]*\(.*\)[ ][ ]*.*`/{\ 47*7c478bd9Sstevel@tonic-gateif [ "$OPTIND" != 1 ]\ 48*7c478bd9Sstevel@tonic-gatethen\ 49*7c478bd9Sstevel@tonic-gate set -- `getopt \1 $*`\ 50*7c478bd9Sstevel@tonic-gateelse\ 51*7c478bd9Sstevel@tonic-gatesedfunc() \ 52*7c478bd9Sstevel@tonic-gate{\ 53*7c478bd9Sstevel@tonic-gateecho "$1" | sed "s\/'\/'\\\\\\\\''\/g"\ 54*7c478bd9Sstevel@tonic-gate}\ 55*7c478bd9Sstevel@tonic-gateexitcode_=0\ 56*7c478bd9Sstevel@tonic-gatewhile getopts \1 c_\ 57*7c478bd9Sstevel@tonic-gatedo\ 58*7c478bd9Sstevel@tonic-gate case $c_ in\ 59*7c478bd9Sstevel@tonic-gate \\?)\ 60*7c478bd9Sstevel@tonic-gate exitcode_=1\ 61*7c478bd9Sstevel@tonic-gate break;;\ 62*7c478bd9Sstevel@tonic-gate *) if [ "$OPTARG" ]\ 63*7c478bd9Sstevel@tonic-gate then\ 64*7c478bd9Sstevel@tonic-gate optarg_=`sedfunc "$OPTARG"`\ 65*7c478bd9Sstevel@tonic-gate arg_="$arg_ '-$c_' '$optarg_'"\ 66*7c478bd9Sstevel@tonic-gate else\ 67*7c478bd9Sstevel@tonic-gate arg_="$arg_ '-$c_'"\ 68*7c478bd9Sstevel@tonic-gate fi;;\ 69*7c478bd9Sstevel@tonic-gate esac\ 70*7c478bd9Sstevel@tonic-gatedone\ 71*7c478bd9Sstevel@tonic-gateshift `expr $OPTIND - 1`\ 72*7c478bd9Sstevel@tonic-gatearg_="$arg_ '--'"\ 73*7c478bd9Sstevel@tonic-gatefor i_ in "$@"\ 74*7c478bd9Sstevel@tonic-gatedo\ 75*7c478bd9Sstevel@tonic-gate optarg_=`sedfunc "$i_"`\ 76*7c478bd9Sstevel@tonic-gate arg_="$arg_ '$optarg_'"\ 77*7c478bd9Sstevel@tonic-gatedone\ 78*7c478bd9Sstevel@tonic-gateeval set -- "$arg_"\ 79*7c478bd9Sstevel@tonic-gatetest $exitcode_ = 0\ 80*7c478bd9Sstevel@tonic-gatefi ;}/ 81*7c478bd9Sstevel@tonic-gate1,$p 82*7c478bd9Sstevel@tonic-gateQ 83*7c478bd9Sstevel@tonic-gate! 84*7c478bd9Sstevel@tonic-gateelse 85*7c478bd9Sstevel@tonic-gate ed <<'!' - $1 86*7c478bd9Sstevel@tonic-gate1,$s/set[ ][ ]*--[ ][ ]*`getopt[ ][ ]*\(.*\)[ ][ ]*.*`/{\ 87*7c478bd9Sstevel@tonic-gatesedfunc()\ 88*7c478bd9Sstevel@tonic-gate{\ 89*7c478bd9Sstevel@tonic-gateecho "$1" | sed "s\/'\/'\\\\\\\\''\/g"\ 90*7c478bd9Sstevel@tonic-gate}\ 91*7c478bd9Sstevel@tonic-gateexitcode_=0\ 92*7c478bd9Sstevel@tonic-gatewhile getopts \1 c_\ 93*7c478bd9Sstevel@tonic-gatedo\ 94*7c478bd9Sstevel@tonic-gate case $c_ in\ 95*7c478bd9Sstevel@tonic-gate \\?)\ 96*7c478bd9Sstevel@tonic-gate exitcode_=1\ 97*7c478bd9Sstevel@tonic-gate break;;\ 98*7c478bd9Sstevel@tonic-gate *) if [ "$OPTARG" ]\ 99*7c478bd9Sstevel@tonic-gate then\ 100*7c478bd9Sstevel@tonic-gate optarg_=`sedfunc "$OPTARG"`\ 101*7c478bd9Sstevel@tonic-gate arg_="$arg_ -$c_ '$optarg_'"\ 102*7c478bd9Sstevel@tonic-gate else\ 103*7c478bd9Sstevel@tonic-gate arg_="$arg_ -$c_"\ 104*7c478bd9Sstevel@tonic-gate fi;;\ 105*7c478bd9Sstevel@tonic-gate esac\ 106*7c478bd9Sstevel@tonic-gatedone\ 107*7c478bd9Sstevel@tonic-gateshift `expr $OPTIND - 1`\ 108*7c478bd9Sstevel@tonic-gatearg_="$arg_ --"\ 109*7c478bd9Sstevel@tonic-gatefor i_ in "$@"\ 110*7c478bd9Sstevel@tonic-gatedo\ 111*7c478bd9Sstevel@tonic-gate optarg_=`sedfunc "$i_"`\ 112*7c478bd9Sstevel@tonic-gate arg_="$arg_ '$optarg_'"\ 113*7c478bd9Sstevel@tonic-gatedone\ 114*7c478bd9Sstevel@tonic-gateeval set -- "$arg_"\ 115*7c478bd9Sstevel@tonic-gatetest $exitcode_ = 0 ;}/ 116*7c478bd9Sstevel@tonic-gate1,$p 117*7c478bd9Sstevel@tonic-gateQ 118*7c478bd9Sstevel@tonic-gate! 119*7c478bd9Sstevel@tonic-gatefi 120