tcsh版本问题(字符串转化为数值)

本文探讨了一段在TCsh shell下执行的简单脚本代码在不同版本TCsh下的执行结果差异。正常版本为tcsh6.13,能正确输出预设字符串;而在tcsh6.14版本中,相同代码却将预设字符串错误地解析为八进制数。通过对比两个版本的TCsh配置选项,推测问题可能源于optionswide与options8b的区别。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

同样程序代码:

    set a = '010'
    @ b = $a
    echo $a
    echo $b

正常机器运行结果:

010

10

异常机器结果:

010

8

正常运行机器的tcsh版本:

tcsh 6.13.00 (Astron) 2004-05-19 (i386-intel-linux) options 8b,nls,dl,al,kan,rh,color,dspm,filec

 

异常运行机器tcsh版本:

tcsh --version:

tcsh 6.14.00 (Astron) 2005-03-25 (i386-intel-linux) options wide,nls,dl,al,kan,sm,rh,color,filec

 

yum info tcsh:
Installed Packages
Name       : tcsh
Arch       : i386
Version    : 6.14
Release    : 14.el5
Size       : 1.1 M
Repo       : installed
Summary    : C シェル csh の強化版
URL        : http://www.tcsh.org/
License    : distributable
Description: Tcsh is an enhanced but completely compatible version of csh, the C
           : shell.  Tcsh is a command language interpreter which can be used
           : both as an interactive login shell and as a shell script command
           : processor. Tcsh includes a command line editor, programmable word
           : completion, spelling correction, a history mechanism, job control
           : and a C language like syntax.

-------------------------------

 

估计是options wide与options 8b的问题

tcsh 6.14支持了8进制?(上面程序中tcsh 6.14把$a当成了8进制数值转换)

 

看来在不改变代码的前提下只能换个版本了。

(待考)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值