Skip to content

Commit

Permalink
Removing function and -f from declare #32
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmysun committed Aug 26, 2024
1 parent 8a72e2e commit 0cebf0c
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
10 changes: 5 additions & 5 deletions helpers/logging.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ logging_debug() {
fi
}

function logging_warn() {
logging_warn() {
if [ "${ELL_LOG_LEVEL}" -ge 4 ]; then
echo "${LOG_STYLE_PUNC}[${LOG_STYLE_RESET}$(date +'%Y-%m-%d %H:%M:%S')${LOG_STYLE_PUNC}]${LOG_STYLE_RESET} $(basename "${0}") ${LOG_STYLE_WARN}WARN${LOG_STYLE_RESET} ${*}" >&2;
fi
}

function logging_info() {
logging_info() {
if [ "${ELL_LOG_LEVEL}" -ge 4 ]; then
printf "%s" "${LOG_STYLE_PUNC}[${LOG_STYLE_RESET}$(date +'%Y-%m-%d %H:%M:%S')${LOG_STYLE_PUNC}]${LOG_STYLE_RESET} $(basename "${0}") " >&2;
fi
Expand All @@ -32,7 +32,7 @@ function logging_info() {
fi
}

function logging_error() {
logging_error() {
if [ "${ELL_LOG_LEVEL}" -ge 4 ]; then
printf "%s" "${LOG_STYLE_PUNC}[${LOG_STYLE_RESET}$(date +'%Y-%m-%d %H:%M:%S')${LOG_STYLE_PUNC}]${LOG_STYLE_RESET} $(basename "${0}") " >&2;
fi
Expand All @@ -41,7 +41,7 @@ function logging_error() {
fi
}

function logging_fatal() {
logging_fatal() {
if [ "${ELL_LOG_LEVEL}" -ge 4 ]; then
printf "%s" "${LOG_STYLE_PUNC}[${LOG_STYLE_RESET}$(date +'%Y-%m-%d %H:%M:%S')${LOG_STYLE_PUNC}]${LOG_STYLE_RESET} $(basename "${0}") " >&2;
fi
Expand All @@ -50,4 +50,4 @@ function logging_fatal() {
fi
}

export -f logging_debug logging_info logging_warn logging_error logging_fatal;
export logging_debug logging_info logging_warn logging_error logging_fatal;
2 changes: 1 addition & 1 deletion helpers/parse_arguments.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ print_version() {
echo "${0} $ELL_VERSION https://github.com/simonmysun/ell";
}

function parse_arguments() {
parse_arguments() {
if [ ${#} -eq 0 ]; then
if [ "x${ELL_RECORD}" = "xtrue" ]; then
logging_debug "Record mode enabled. Context is used.";
Expand Down
2 changes: 1 addition & 1 deletion helpers/piping.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ piping() {
fi
}

export -f piping;
export piping;
4 changes: 2 additions & 2 deletions llm_backends/ell_echo/generate_completion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

# This is a dummy function that echoes the input. Designed for debugging and testing purposes.

function generate_completion() {
generate_completion() {
cat -;
}

export -f generate_completion;
export generate_completion;
4 changes: 2 additions & 2 deletions llm_backends/gemini/generate_completion.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

function generate_completion() {
generate_completion() {
if [ "x${ELL_API_STREAM}" != "xtrue" ]; then
logging_debug "Streaming disabled";
response=$(cat - | curl "${ELL_API_URL}${ELL_LLM_MODEL}:generateContent" \
Expand Down Expand Up @@ -93,4 +93,4 @@ function generate_completion() {
fi
}

export -f generate_completion;
export generate_completion;
4 changes: 2 additions & 2 deletions llm_backends/openai/generate_completion.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

function generate_completion() {
generate_completion() {
if [ "x${ELL_API_STREAM}" != "xtrue" ]; then
logging_debug "Streaming disabled";
response=$(cat - | curl "${ELL_API_URL}" \
Expand Down Expand Up @@ -81,4 +81,4 @@ function generate_completion() {
fi
}

export -f generate_completion;
export generate_completion;
2 changes: 1 addition & 1 deletion plugins/syntax_highlight/50_post_llm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if [ "x${TO_TTY}" = "xtrue" ]; then

CURRENT_LINE="";

function current_style() {
current_style() {
# Set the style based on the current state of the syntax highlighting.
printf "%b" "${STYLE_RESET}";
if [ "x${IN_LINK_TEXT}" = "xtrue" ]; then
Expand Down
4 changes: 2 additions & 2 deletions tests/piping.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

set -o posix;

function inc() {
inc() {
while read -r -N 1 char; do
printf '%s' $(( (char + 1) % 10 ));
done
}

export -f inc;
export -f inc; # why -f is necessary?

. "$(dirname "${0}")/../helpers/piping.sh";

Expand Down

0 comments on commit 0cebf0c

Please sign in to comment.