当前位置:   article > 正文

readonly只读变量的设置与取消_-bash: prompt_command: readonly variable

-bash: prompt_command: readonly variable

source /etc/profile 出现 bash:PROMPT-COMMAND: 只读变量
利用unset命令是无法删除只读变量的

 如果需要取消设置的只读变量需要用到gdb命令可以使用rpm -q gdb查看下自己系统中是否有该命令,没有的话可以yum -y install gdb安装下

下载好可以使用下面的方法取消下

  1. [root@zyf ~]# cat <<EOF |gdb
  2. > attach $$
  3. > call unbind_variable("name")
  4. > detach
  5. > EOF
  6. GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-120.el7
  7. Copyright (C) 2013 Free Software Foundation, Inc.
  8. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
  9. This is free software: you are free to change and redistribute it.
  10. There is NO WARRANTY, to the extent permitted by law. Type "show copying"
  11. and "show warranty" for details.
  12. This GDB was configured as "x86_64-redhat-linux-gnu".
  13. For bug reporting instructions, please see:
  14. <http://www.gnu.org/software/gdb/bugs/>.
  15. (gdb) Attaching to process 15886
  16. Reading symbols from /usr/bin/bash...Reading symbols from /usr/bin/bash...(no debugging symbols found)...done.
  17. (no debugging symbols found)...done.
  18. Reading symbols from /lib64/libtinfo.so.5...Reading symbols from /lib64/libtinfo.so.5...(no debugging symbols found)...done.
  19. (no debugging symbols found)...done.
  20. Loaded symbols for /lib64/libtinfo.so.5
  21. Reading symbols from /lib64/libdl.so.2...(no debugging symbols found)...done.
  22. Loaded symbols for /lib64/libdl.so.2
  23. Reading symbols from /lib64/libc.so.6...(no debugging symbols found)...done.
  24. Loaded symbols for /lib64/libc.so.6
  25. Reading symbols from /lib64/ld-linux-x86-64.so.2...(no debugging symbols found)...done.
  26. Loaded symbols for /lib64/ld-linux-x86-64.so.2
  27. Reading symbols from /lib64/libnss_files.so.2...(no debugging symbols found)...done.
  28. Loaded symbols for /lib64/libnss_files.so.2
  29. 0x00007fa89ba38a3c in waitpid () from /lib64/libc.so.6
  30. Missing separate debuginfos, use: debuginfo-install bash-4.2.46-31.el7.x86_64
  31. (gdb) $1 = 0
  32. (gdb) Detaching from program: /usr/bin/bash, process 15886
  33. [Inferior 1 (process 15886) detached]
  34. (gdb) quit

上面的执行完成后再重新对name进行赋值

  1. [root@zyf ~]# name=lisi
  2. [root@zyf ~]# echo $name
  3. lisi

 可以看到已经可以重新对name变量进行赋值了

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/288120
推荐阅读
相关标签
  

闽ICP备14008679号