forked from LinuxCNC/linuxcnc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinuxcnc_var.in
More file actions
95 lines (85 loc) · 2.38 KB
/
linuxcnc_var.in
File metadata and controls
95 lines (85 loc) · 2.38 KB
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
#!/bin/bash
# maintainer: when adding items update three places:
# usage(), show_all(), and show_item()
#
# note: report LINUXCNVERSION=$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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
function usage () {
cat <<EOF
Retrieve Linuxcnc Variables
Usage:
$(basename $0) [ varname | all ]
Varnames supported:
LINUXCNCVERSION
REALTIME
RTS
HALLIB_DIR
Option 'all' returns varname=value for all supported varnames
EOF
exit 1
}
function show_all () {
echo "LINUXCNCVERSION=@EMC2VERSION@
REALTIME=@REALTIME@
RTS=@RTS@
HALLIB_DIR=@HALLIB_DIR@"
}
function show_item () {
case $1 in
LINUXCNCVERSION) echo @EMC2VERSION@;;
REALTIME) echo @REALTIME@;;
RTS) echo @RTS@;;
HALLIB_DIR) echo @HALLIB_DIR@;;
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)