1 # --- SDE-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
4 # Filename: lib/sde-wrapper-discriminator.in
5 # Copyright (C) 2008 The OpenSDE Project
7 # More information can be found in the files COPYING and README.
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; version 2 of the License. A copy of the
12 # GNU General Public License can be found in the file COPYING.
13 # --- SDE-COPYRIGHT-NOTE-END ---
15 # include the generic sde_wrapper functions
16 . "$SDEROOT/lib/sde-wrapper.in"
18 # list all the valid discriminators for a given command
20 sde_wrapper_discriminator_list() {
21 ls -1d "$SDEROOT/bin/sde-$1-"* 2> /dev/null
24 # return the usage of every discriminator
25 sde_wrapper_discriminator_help() {
26 local toy= name= desc= aliases=
28 Usage: sde $1 <discriminator> [OPTIONS] [ARGUMENTS]
30 Available Discriminators:
32 for toy in $( sde_wrapper_discriminator_list "$1" ); do
33 name=$( sde_wrapper_name "$toy" )
34 desc=$( sde_wrapper_desc "$toy" )
35 aliases=$( sde_wrapper_aliases "$toy" )
37 printf "%15s %s%s\n" "$name" "${desc:-...}" "${aliases:+ (Alias: ${aliases// /,})}"
41 For more information try: sde $1 <discriminator> --help
45 sde_wrapper_discriminator() {
46 local combin= command="$1"; shift
47 local discriminators=$( sde_wrapper_discriminator_list $command )
49 if [ "$1" != "${1%-*}" ]; then
50 # trying to cheat, no dashes alowed
52 elif [ -x "$SDEROOT/bin/sde-$command-$1" ]; then
53 # discriminator given explicitly
55 elif [ -n "$discriminators" ]; then
56 # given token may be an alias of a valid discriminator for this command
57 combin=$( grep -l "^#Alias: $1$" $discriminators | head -n 1 )
58 echo $( sde_wrapper_name "$combin" )