Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. # Returns an eval-safe representation of the bash function that when evaluated prints its name,
  4. # useful when redefining functions
  5. function_copy_rnd () {
  6. local rand_prefix="$(head /dev/urandom | tr -dc A-Za-z | head -c 8)_"
  7. local name="$1"
  8. local decl;
  9. decl="$(declare -f "$name")" || return $?
  10. echo "${rand_prefix}${decl}; echo $(printf "%q" "${rand_prefix}${name}")"
  11. return 0;
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement