#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#define PATH_PREFIX "--cd="
char *path_cpoy(char *dst, const char *src, int len)
{
char c;
while (len--) {
c = *src;
if (c == ' ') {
*dst++ = '"';
do {
*dst++ = ' ';
src++;
} while (*src == ' ');
*dst++ = '"';
} else {
*dst++ = c;
src++;
}
}
return dst;
}
int main(int argc, char *argv[])
{
char cmd[1024];
char *p;
int len;
int size;
size = sizeof(cmd);
p = cmd;
// xx\xx\git-bash.exe "--cd=%v."
len = strlen(argv[0])-3;
p = path_cpoy(p, argv[0], len);
*p++ = 'b';
*p++ = 'a';
*p++ = 't';
*p++ = ' ';
*p = '\0';
size -= len + 3 + 5;
if (argc == 2) {
if (memcmp(argv[1], PATH_PREFIX, sizeof(PATH_PREFIX)-1)) {
fprintf(stderr, "only support \"--cd=path.\"\r\n");
goto RUN;
}
len = strlen(argv[1]);
if (argv[1][len-1] != '.') {
fprintf(stderr, "\"--cd=path.\" should endwith \".\"\r\n");
goto RUN;
}
len -= sizeof(PATH_PREFIX)-1;
if (len > size) {
fprintf(stderr, "the length of path if too long\r\n");
goto RUN;
}
p = path_cpoy(p, &argv[1][sizeof(PATH_PREFIX)-1], len);
*p = '\0';
}
RUN:
system(cmd);
return 0;
}
没有合适的资源?快使用搜索试试~ 我知道了~
环境配置 - Git-Bash
共8个文件
o:2个
rc:1个
c:1个
0 下载量 55 浏览量
2024-01-17
15:17:20
上传
评论
收藏 20KB ZIP 举报
温馨提示
git-bash工程
资源推荐
资源详情
资源评论
收起资源包目录
win_bash.zip (8个子文件)
win_bash
Makefile 1KB
resource
icon.rc 34B
icons
bash.ico 3KB
git-bash.exe 49KB
.obj
icon.o 3KB
main.d 21B
main.o 2KB
main.c 1KB
共 8 条
- 1
资源评论
xflm
- 粉丝: 44
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功