-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmake_lsm.bash
More file actions
executable file
·61 lines (52 loc) · 2.86 KB
/
Copy pathmake_lsm.bash
File metadata and controls
executable file
·61 lines (52 loc) · 2.86 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
#!/bin/bash
#
# MAKE LSM FILE
#
# Version 1.0: 11 December 2019. Produced by Andy Foreman.
# Version 1.1: 17 July 2020. Produced by Andy Foreman. Added read of version from built file and reminder message to support Git deployment and version-check strategy.
##########
# This is a development utility to build the SAS_lsm master script file.
# Not intended for use by end-customers. It can be safely ignored or deleted.
#
# USAGE:
#
# 1) Place this file in the root directory of the SAS_lsm package (the place where the master file should be generated)
# 2) Ensure a subdirectory "lsm_components" containing desired components exists under this script's executing directory and is readable
# 3) Run this script, the output file will be saved in the current working directory (make sure you can write there)
# - You can specify an output filename directly in the command call, i.e. `./make_lsm.bash myfilename`
# - If you do not specify an output filename in the command call, you will be prompted to enter one before the output file is generated
# 4) THE OUTPUT FILENAME WILL BE OVERWRITTEN!
#
# NOTES:
#
# - As a development utility, there is no input-validation or error-checking here.
#
# - The "lsm_components" subdirectory will be searched in the following order:
# 1) Any .txt files (expected to be comments at top of output script)
# 2) Any .fn files (expected to be the individual script functions of SAS_lsm)
# 3) The file "main.main" (expected to contain main function calls and anything else that cannot go inside a function)
#
# - The output script will be written out in the order of files searched. Logically this means you get .txt files (comments) at the top, the individual .fn files (functions) in any order, and then the main.main file (main instructions) at the bottom.
##########
pwd="$(pwd)"
dirname="$(dirname $0)"
outfile=$1
if [ -z "$outfile" ] #if user did not specify outfile name in command, ask for it
then
read -e -p "Specify output file name: " outfile
fi
echo -n > $pwd/$outfile #delete outfile contents, if exists
find $dirname/lsm_components/ | grep .*.txt | while read filename; do
cat $filename >> $pwd/$outfile
done
find $dirname/lsm_components/ | grep .*.fn | while read filename; do #loop through each filename in defined path, and subdirs technically
cat $filename >> $pwd/$outfile
done
find $dirname/lsm_components/ | grep main.main | while read filename; do
cat $filename >> $pwd/$outfile
done
echo "File has been built and saved at path: $pwd/$outfile"
echo ""
CURRVERSION=$(head -q -n 30 "${pwd}/${outfile}" | grep "SAS_lsm Utility: Version" | sed 's/[^0-9.]*//g' | sed 's/\.$//')
echo "New build version is marked as ${CURRVERSION}"
echo "If you are planning on making a new RELEASE PACKAGE for this build, check that you have updated lsm_components/header.txt to increment the build version over current release!!!"