Bash trap on exit from function

Yes, you can trap RETURN : $ function foo() { > trap “echo finished” RETURN > echo “doing some things” > } $ foo Will display doing some things finished From man bash‘s description of the trap builtin : If a sigspec is RETURN, the command arg is executed each time a shell function or … Read more

How to get function parameter lists (so I can drop a function)

Postgres has a dedicated function for that purpose. Introduced with Postgres 8.4. The manual: pg_get_function_identity_arguments(func_oid) … get argument list to identify a function (without default values) … pg_get_function_identity_arguments returns the argument list necessary to identify a function, in the form it would need to appear in within ALTER FUNCTION, for instance. This form omits default … Read more

Python modules with submodules and functions

A folder with .py files and a __init__.py is called a package. One of those files containing classes and functions is a module. Folder nesting can give you subpackages. So for example if I had the following structure: mypackage __init__.py module_a.py module_b.py mysubpackage __init__.py module_c.py module_d.py I could import mypackage.module_a or mypackage.mysubpackage.module_c and so on. … Read more

What type is a function name in C? [duplicate]

What type is a function name in C? A function name or function designator has a function type. When it is used in an expression, except when it is the operand of sizeof or & operator, it is converted from type “function returning type” to type “pointer to a function returning type”. (This is specified … Read more

Ruby – print the variable name and then its value

Sure it is possible! My solution tests the var by Object#object_id identity: http://codepad.org/V7TXRxmL It’s crippled in the binding passing style … Although it works just for local vars yet, it can be easily be made “universal” adding use of the other scope-variable-listing methods like instance_variables etc. # the function must be defined in such a … Read more

Split function in oracle to comma separated values with automatic sequence

Here is how you could create such a table: SELECT LEVEL AS id, REGEXP_SUBSTR(‘A,B,C,D’, ‘[^,]+’, 1, LEVEL) AS data FROM dual CONNECT BY REGEXP_SUBSTR(‘A,B,C,D’, ‘[^,]+’, 1, LEVEL) IS NOT NULL; With a little bit of tweaking (i.e., replacing the , in [^,] with a variable) you could write such a function to return a table.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)