File: linuxcnc_var.in

package info (click to toggle)
linuxcnc 1%3A2.9.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 285,604 kB
  • sloc: python: 202,568; ansic: 109,036; cpp: 99,239; tcl: 16,054; xml: 10,631; sh: 10,303; makefile: 1,255; javascript: 138; sql: 72; asm: 15
file content (104 lines) | stat: -rw-r--r-- 2,769 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/bash
# maintainer: when adding items update three places:
#             usage(), show_all(), and show_item()
#
# note: report LINUXCNCVERSION=$EMC2VERSION (as does linuxcnc.in)

# Copyright: 2014
# Author:    Dewey Garrett <dgarrett@panix.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
function usage () {
  cat <<EOF

Retrieve Linuxcnc Variables
Usage:
      $(basename $0) [ varname | all ]

Varnames supported:
         LINUXCNCVERSION
         LINUXCNC_AUX_GLADEVCP
         LINUXCNC_AUX_EXAMPLES
         REALTIME
         RTS
         HALLIB_DIR
         PYTHON

Option 'all' returns varname=value for all supported varnames
EOF
exit 1
}

function show_all () {
  echo "LINUXCNCVERSION=@EMC2VERSION@
LINUXCNC_AUX_GLADEVCP=@LINUXCNC_AUX_GLADEVCP@
LINUXCNC_AUX_EXAMPLES=@LINUXCNC_AUX_EXAMPLES@
REALTIME=@REALTIME@
RTS=@RTS@
HALLIB_DIR=@HALLIB_DIR@
PYTHON=@PYTHON@"
}

function show_item () {
  case $1 in
    LINUXCNCVERSION) echo @EMC2VERSION@;;
    LINUXCNC_AUX_GLADEVCP) echo @LINUXCNC_AUX_GLADEVCP@;;
    LINUXCNC_AUX_EXAMPLES) echo @LINUXCNC_AUX_EXAMPLES@;;
    REALTIME) echo @REALTIME@;;
    RTS) echo @RTS@;;
    HALLIB_DIR) echo @HALLIB_DIR@;;
    PYTHON) echo @PYTHON@;;
    all) show_all;;
    *) echo UNKNOWN; exit 1;;
  esac
}

case $# in
   0) usage;;
   1) show_item $1;;
   *) usage;;
esac
exit 0

# Example shell usage to populate environment in a sourced script:
# for line in $(linuxcnc_var all) ; do
#   name=${line%%=*}
#   value=${line##*=}
#   echo "name=$name value=$value"
#   export "$name"="$value"
# done

# Example tcl usage:
# foreach line [exec linuxcnc_var all] {
#   set l [split $line =]
#   set name  [lindex $l 0]
#   set value [lindex $l 1]
#   set V($name) $value
# }
# parray V

# Example python usage:
# import subprocess
# s   = subprocess.Popen(['linuxcnc_var','all']
#                       ,stdout=subprocess.PIPE
#                       ,stderr=subprocess.PIPE
# p,e = s.communicate()
# v={}
# for line in p.split('\n'):
#     if line == '': continue
#     name = line.split('=')[0]
#     value = line.split('=')[1]
#     v[name] = value
# print(v)