Print this page
XXX Remove nawk(1)

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/svc/shell/routing_include.sh
          +++ new/usr/src/cmd/svc/shell/routing_include.sh
↓ open down ↓ 161 lines elided ↑ open up ↑
 162  162          OPTIND=1
 163  163          # Skip options
 164  164          while getopts $3 opt $2; do
 165  165                  case $opt in
 166  166                          ? )
 167  167                  esac
 168  168          done
 169  169          pos=$OPTIND
 170  170          for prop in $4
 171  171          do
 172      -                val=`/usr/bin/echo $2 | /usr/bin/nawk -v POS=$pos \
      172 +                val=`/usr/bin/echo $2 | /usr/xpg4/bin/awk -v POS=$pos \
 173  173                      '{ print $POS }'`
 174  174                  if [ -z "$val" ]; then
 175  175                          val="$5"
 176  176                  fi
 177  177                  set_routeadm_property $1 $prop $val
 178  178                  pos=`expr $pos + 1`
 179  179          done
 180  180  }
 181  181  
 182  182  #
 183  183  # get_daemon_args $inst_fmri
 184  184  #
 185  185  # Retrieves routeadm/daemon-args property values, if any.  Removes
 186  186  # quotes around values including spaces.
 187  187  #
 188  188  get_daemon_args()
 189  189  {
 190  190          args=`/usr/sbin/svccfg -s $1 listprop routeadm/daemon-args | \
 191      -            /usr/bin/nawk '{ for (i = 3; i <= NF; i++) printf "%s ", $i }' | \
 192      -            /usr/bin/nawk '{sub(/^\"/, ""); sub(/\"[ \t]*$/,""); print}'`
      191 +            /usr/xpg4/bin/awk '{ for (i = 3; i <= NF; i++) printf "%s ", $i }' | \
      192 +            /usr/xpg4/bin/awk '{sub(/^\"/, ""); sub(/\"[ \t]*$/,""); print}'`
 193  193          echo "$args"
 194  194  }
 195  195  
 196  196  #
 197  197  # clear_daemon_args $inst_fmri
 198  198  #
 199  199  # Blanks routeadm/daemon-args property used in upgrade.
 200  200  #
 201  201  clear_daemon_args()
 202  202  {
 203  203          /usr/sbin/svccfg -s $1 delprop routeadm/daemon-args 2>/dev/null
 204  204  }
 205  205  
 206  206  #
 207  207  # The functions below are used to map back from property settings to
 208  208  # commandline arguments to launch daemons.
 209  209  #
 210  210  
 211  211  get_routeadm_property()
 212  212  {
 213      -        propval=`/sbin/routeadm -l $1 | /usr/bin/nawk -v PROP=$2 \
      213 +        propval=`/sbin/routeadm -l $1 | /usr/xpg4/bin/awk -v PROP=$2 \
 214  214              '($1 == PROP) { for (i = 3; i < NF; i++) printf $i" "; \
 215  215              if (NF >= 3) {printf $NF}}'`
 216  216          echo "$propval"
 217  217  }
 218  218  
 219  219  #
 220  220  # get_daemon_option_from_boolean_property inst_fmri prop option value_set
 221  221  #
 222  222  # Returns appropriate daemon option for boolean property prop - if current
 223  223  # value matches value_set.
↓ open down ↓ 24 lines elided ↑ open up ↑
 248  248  # get_daemon_ordered_multivalue_option_from_property inst_fmri prop
 249  249  # option
 250  250  #
 251  251  # Returns appropriate daemon option and associated values. Values are
 252  252  # unquoted, i.e. -A value1 -A value2
 253  253  #
 254  254  get_daemon_ordered_multivalue_option_from_property()
 255  255  {
 256  256          # get property values, removing trailing delimiter.
 257  257          propvals=`get_routeadm_property $1 $2 | \
 258      -            /usr/bin/nawk '{sub(/;[ \t]*$/, ""); print }'`
      258 +            /usr/xpg4/bin/awk '{sub(/;[ \t]*$/, ""); print }'`
 259  259          # Substitute switch for internal delimiters.
 260  260          fixed_propvals=`/usr/bin/echo $propvals | \
 261      -            /usr/bin/nawk -v SWITCH=" -${3} " \
      261 +            /usr/xpg4/bin/awk -v SWITCH=" -${3} " \
 262  262              '{sub(/;/, SWITCH); print }'`
 263  263          if [ -n "$fixed_propvals" ]; then
 264  264                  echo "-${3} $fixed_propvals"
 265  265          fi
 266  266  }
 267  267  
 268  268  #
 269  269  # get_nonoption_property inst_fmri prop ignore_value
 270  270  #
 271  271  # Returns appropriate non-option property (at end of option list), unless
 272  272  # value matches ignore value, in which case nothing is returned.
 273  273  #
 274  274  get_daemon_nonoption_property()
 275  275  {
 276  276          propval=`get_routeadm_property $1 $2`
 277  277          if [ -n "$propval" -a "$propval" != "$3" ]; then
 278  278                  echo "$propval"
 279  279          fi
 280  280  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX