路径初始化:preventing“输入行太长”

编程入门 行业动态 更新时间:2024-10-23 12:25:20
本文介绍了路径初始化:preventing“输入行太长”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有人说,他们的路径太长,然而,问题往往是由同样的批处理脚本反复调用导致与code像集mypath中=%mypath中%;附录。 人们只是没有意识到。我提出了一个搜索解决方案ñ退出时恢​​复ENV变量

Some people say that their path is too long, However, the problem is often caused by recurring call of the same batch script with code like set mypath=%mypath%;appendix. People just do not realize that. I proposed a solution to restore the env variables upon exit

set old_path=classpath set classpath=%classpath%;appendix java myApp set classpath=old_path

但它是单调乏味而且容易出错。我可以很容易忘记恢复或失败的原因外,另一个出口路径。可以这样自动完成?

But it is tedious and error prone. I may easily forget to recover or fail due to exception, another exit path. Can this be done automatically?

我们可以用智能附录开始。我的意思是,这个问题是由无条件附加的路径而引起的。你已经有你的路径上的阑尾却一遍遍重新添加。这是问题的根源。我认为同样的问题适用于抨击。可能是我可以检查路径和只添加那些缺失的条目?标准的解决方案是什么?

We can start with a smart appendix. I mean that the problem is caused by appending the path unconditionally. You already have the appendix on your path but add it over and over again. That is the root of the problem. I think that the same problem applies to bash. Might be I can check the path and add only those entries which are missing? What is the standard solution?

推荐答案

首先,你的code不能正常工作,例如, old_path 是您的最后一个命令字符串。

first, your code can't work, e.g. old_path is a string in your last command.

set "old_path=%classpath%" set "classpath=%classpath%;%appendix%" java myApp set "classpath=%old_path%"

第二,只需使用一个新的环境,在批避免这样的问题:

second, just use a new environment in the batch to avoid such issues:

@echo off echo %path% setlocal set "path=" echo %path% endlocal echo %path%

更多推荐

路径初始化:preventing“输入行太长”

本文发布于:2023-07-14 22:03:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1107283.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:初始化   太长   路径   preventing

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!