Как Вы называете функцию, определяемую в .bashrc от оболочки?

От документация CREATE TRIGGER :

удалил , и вставил , логические (концептуальные) таблицы. Они структурно подобны таблице, на которой триггер определяется, то есть, таблица, на которой предпринято пользовательское действие, и содержат старые значения или новые значения строк, которые могут быть изменены пользовательским действием. Например, для получения всех значений в удаленной таблице используйте: SELECT * FROM deleted

Так, чтобы, по крайней мере, дал Вам способ видеть новые данные.

я не вижу ничего в документах, которое определяет, что Вы не будете видеть вставленные данные при запросах нормальной таблицы хотя...

55
задан les2 30 September 2009 в 20:50
поделиться

4 ответа

The test in your function won't work - you should not have brackets around the -z clauses, and there should be a space between if and the open bracket. It should read:

function coolness() {

    if [ -z "$1" -o -z "$2" ]; then
        echo "Usage: $0 [sub_package] [endpoint]";
        exit 1;
    fi
    echo "Hi!"
}
27
ответ дан 26 November 2019 в 17:48
поделиться

You can export functions. In your ~/.bashrc file after you define the function, add export -f functionname.

function hello() {
   echo "Hello, $1!"
}

export -f hello

Then the function will be available at the shell prompt and also in other scripts that you call from there.

Note that it's not necessary to export functions unless they are going to be used in child processes (the "also" in the previous sentence). Usually, even then, it's better to source the function into the file in which it will be used.

Edit:

Brackets in Bash conditional statements are not brackets, they're commands. They have to have spaces around them. If you want to group conditions, use parentheses. Here's your function:

function coolness() {

    if [ -z "$1" -o -z "$2" ]; then
        echo "Usage: $0 [sub_package] [endpoint]";
        exit 1;
    fi
        echo "Hi!"
}

A better way to write that conditional is:

    if [[ -z "$1" || -z "$2" ]]; then

because the double brackets provide more capability than the single ones.

72
ответ дан 26 November 2019 в 17:48
поделиться

Include in your script the line

source .bashrc

try with the source construct it should work!

17
ответ дан 26 November 2019 в 17:48
поделиться
$ source .bashrc
4
ответ дан 26 November 2019 в 17:48
поделиться