mirror of
https://github.com/natelandau/shell-scripting-templates.git
synced 2025-11-12 06:53:48 -05:00
use 4 spaces for indent
This commit is contained in:
@@ -1,34 +1,34 @@
|
||||
_makeCSV_() {
|
||||
# Creates a new CSV file if one does not already exist
|
||||
# Takes passed arguments and writes them as a header line to the CSV
|
||||
# Usage '_makeCSV_ column1 column2 column3'
|
||||
# Creates a new CSV file if one does not already exist
|
||||
# Takes passed arguments and writes them as a header line to the CSV
|
||||
# Usage '_makeCSV_ column1 column2 column3'
|
||||
|
||||
# Set the location and name of the CSV File
|
||||
if [ -z "${csvLocation}" ]; then
|
||||
csvLocation="${HOME}/Desktop"
|
||||
fi
|
||||
if [ -z "${csvName}" ]; then
|
||||
csvName="$(LC_ALL=C date +%Y-%m-%d)-${FUNCNAME[1]}.csv"
|
||||
fi
|
||||
csvFile="${csvLocation}/${csvName}"
|
||||
|
||||
# Overwrite existing file? If not overwritten, new content is added
|
||||
# to the bottom of the existing file
|
||||
if [ -f "${csvFile}" ]; then
|
||||
if _seekConfirmation_ "${csvFile} already exists. Overwrite?"; then
|
||||
rm "${csvFile}"
|
||||
# Set the location and name of the CSV File
|
||||
if [ -z "${csvLocation}" ]; then
|
||||
csvLocation="${HOME}/Desktop"
|
||||
fi
|
||||
fi
|
||||
_writeCSV_ "$@"
|
||||
if [ -z "${csvName}" ]; then
|
||||
csvName="$(LC_ALL=C date +%Y-%m-%d)-${FUNCNAME[1]}.csv"
|
||||
fi
|
||||
csvFile="${csvLocation}/${csvName}"
|
||||
|
||||
# Overwrite existing file? If not overwritten, new content is added
|
||||
# to the bottom of the existing file
|
||||
if [ -f "${csvFile}" ]; then
|
||||
if _seekConfirmation_ "${csvFile} already exists. Overwrite?"; then
|
||||
rm "${csvFile}"
|
||||
fi
|
||||
fi
|
||||
_writeCSV_ "$@"
|
||||
}
|
||||
|
||||
_writeCSV_() {
|
||||
# Takes passed arguments and writes them as a comma separated line
|
||||
# Usage '_writeCSV_ column1 column2 column3'
|
||||
# Takes passed arguments and writes them as a comma separated line
|
||||
# Usage '_writeCSV_ column1 column2 column3'
|
||||
|
||||
local csvInput=("$@")
|
||||
saveIFS=$IFS
|
||||
IFS=','
|
||||
echo "${csvInput[*]}" >>"${csvFile}"
|
||||
IFS=${saveIFS}
|
||||
local csvInput=("$@")
|
||||
saveIFS=$IFS
|
||||
IFS=','
|
||||
echo "${csvInput[*]}" >>"${csvFile}"
|
||||
IFS=${saveIFS}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user