mirror of
https://github.com/roswell/roswell.git
synced 2026-09-10 07:16:17 -04:00
refer environment variable.
This commit is contained in:
parent
7efe13fece
commit
607bbdaaa8
|
|
@ -86,7 +86,7 @@ int download(struct install_options* param)
|
|||
char* archive_name=download_archive_name(param);
|
||||
char* impl_archive=cat(home,"archives",SLASH,archive_name,NULL);
|
||||
if(!file_exist_p(impl_archive)
|
||||
|| get_opt("download.force")) {
|
||||
|| get_opt("download.force",1)) {
|
||||
printf("Downloading archive.:%s\n",url);
|
||||
/*TBD proxy support... etc*/
|
||||
if(url) {
|
||||
|
|
|
|||
|
|
@ -36,9 +36,9 @@ char** cmd_run_ccl(int argc,char** argv,struct sub_command* cmd)
|
|||
int paramc=0;
|
||||
char* impl_path= cat(home,"impls",SLASH,arch,SLASH,os,SLASH,impl,SLASH,version,NULL);
|
||||
char* bin;
|
||||
char* script=get_opt("script");
|
||||
char* image=get_opt("image");
|
||||
char* program=get_opt("program");
|
||||
char* script=get_opt("script",0);
|
||||
char* image=get_opt("image",0);
|
||||
char* program=get_opt("program",0);
|
||||
int issystem=(strcmp("system",version)==0);
|
||||
if(issystem){
|
||||
bin=truename(which("ccl"));
|
||||
|
|
|
|||
|
|
@ -16,13 +16,13 @@ char** cmd_run_sbcl(int argc,char** argv,struct sub_command* cmd)
|
|||
--no-sysinit --no-userinit [terminating NULL] that total 9 are default. */
|
||||
int i;
|
||||
char* impl_path= cat(home,"impls",SLASH,arch,SLASH,os,SLASH,impl,SLASH,version,NULL);
|
||||
char* help=get_opt("help");
|
||||
char* script=get_opt("script");
|
||||
char* image=get_opt("image");
|
||||
char* program=get_opt("program");
|
||||
char* dynamic_space_size=get_opt("dynamic-space-size");
|
||||
char* dynamic_stack_size=get_opt("dynamic-stack-size");
|
||||
char* sbcl_version=get_opt("version");
|
||||
char* help=get_opt("help",0);
|
||||
char* script=get_opt("script",0);
|
||||
char* image=get_opt("image",0);
|
||||
char* program=get_opt("program",0);
|
||||
char* dynamic_space_size=get_opt("dynamic-space-size",0);
|
||||
char* dynamic_stack_size=get_opt("dynamic-stack-size",0);
|
||||
char* sbcl_version=get_opt("version",0);
|
||||
int paramc=0;
|
||||
char *bin;
|
||||
int issystem=(strcmp("system",version)==0);
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ int cmd_run_star(int argc,char **argv,struct sub_command* cmd);
|
|||
|
||||
int cmd_run(int argc,char **argv,struct sub_command* cmd)
|
||||
{
|
||||
char* current=get_opt("program");
|
||||
char* current=get_opt("program",0);
|
||||
if(verbose>0)
|
||||
fprintf(stderr,"cmd_%s:argc=%d argv[0]=%s\n",cmd->name,argc,argv[0]);
|
||||
if(argc==1 && !current) {
|
||||
|
|
@ -42,7 +42,7 @@ int cmd_run(int argc,char **argv,struct sub_command* cmd)
|
|||
}else {
|
||||
int i;
|
||||
for(i=1;i<argc;i+=proccmd(argc-i,&argv[i],run_options,run_commands));
|
||||
current=get_opt("program");
|
||||
current=get_opt("program",0);
|
||||
if(strcmp((char*)cmd->name,ROS_RUN_REPL)!=0) {
|
||||
char* tmp[]={"--"};
|
||||
proccmd(1,tmp,run_options,run_commands);
|
||||
|
|
@ -60,7 +60,7 @@ int cmd_run(int argc,char **argv,struct sub_command* cmd)
|
|||
|
||||
int cmd_script(int argc,char **argv,struct sub_command* cmd)
|
||||
{
|
||||
char* current=get_opt("program");
|
||||
char* current=get_opt("program",0);
|
||||
if(verbose>0)
|
||||
fprintf(stderr,"script_%s:argc=%d argv[0]=%s\n",cmd->name,argc,argv[0]);
|
||||
if(argc==1 && !current &&
|
||||
|
|
@ -138,7 +138,7 @@ char* ql_path(void) {
|
|||
if(env_ql){
|
||||
env_ql=q(env_ql);
|
||||
}else {
|
||||
env_ql=q(get_opt("quicklisp"));
|
||||
env_ql=q(get_opt("quicklisp",0));
|
||||
}
|
||||
env_ql=append_trail_slash(env_ql);
|
||||
return env_ql;
|
||||
|
|
@ -161,7 +161,7 @@ int cmd_run_star(int argc,char **argv,struct sub_command* cmd)
|
|||
#else
|
||||
char* etc="/etc/rosrc";
|
||||
#endif
|
||||
char* current=get_opt("program");
|
||||
char* current=get_opt("program",0);
|
||||
char *path,*would;
|
||||
if(file_exist_p(init)) {
|
||||
path=cat("(:load \"",init,"\")",NULL);
|
||||
|
|
@ -171,7 +171,7 @@ int cmd_run_star(int argc,char **argv,struct sub_command* cmd)
|
|||
s(path);
|
||||
}
|
||||
s(init);
|
||||
current=get_opt("program");
|
||||
current=get_opt("program",0);
|
||||
if(file_exist_p(etc)) {
|
||||
path=cat("(:load \"",etc,"\")",NULL);
|
||||
would=cat(path,current?current:"",NULL);
|
||||
|
|
@ -182,16 +182,16 @@ int cmd_run_star(int argc,char **argv,struct sub_command* cmd)
|
|||
fprintf(stderr,"cmd_run_star:%s argc=%d argv[0]=%s \n",cmd->name,argc,argv[0]);
|
||||
fprintf(stderr,"localopt:%s\n",sexp_opts(local_opt));
|
||||
}
|
||||
impl=get_opt("lisp");
|
||||
impl=get_opt("lisp",1);
|
||||
if(impl && (pos=position_char("/",impl))!=-1) {
|
||||
version=subseq(impl,pos+1,0);
|
||||
impl=subseq(impl,0,pos);
|
||||
}else {
|
||||
if(!impl)
|
||||
impl=get_opt("default.lisp");
|
||||
impl=get_opt("default.lisp",1);
|
||||
if(impl) {
|
||||
char* opt=s_cat(q(impl),q("."),q("version"),NULL);
|
||||
version=get_opt(opt);
|
||||
version=get_opt(opt,1);
|
||||
s(opt);
|
||||
}
|
||||
if(impl)
|
||||
|
|
@ -203,7 +203,7 @@ int cmd_run_star(int argc,char **argv,struct sub_command* cmd)
|
|||
if(impl) {
|
||||
char** arg=NULL;
|
||||
int i;
|
||||
char* wrap=get_opt("wrap");
|
||||
char* wrap=get_opt("wrap",1);
|
||||
set_opt(&local_opt,"impl",cat(impl,"/",version,NULL),0);
|
||||
{
|
||||
struct sub_command cmd;
|
||||
|
|
|
|||
10
src/lsp.c
10
src/lsp.c
|
|
@ -190,7 +190,7 @@ int opt_top_ql(int argc,char** argv,struct sub_command* cmd) {
|
|||
|
||||
int opt_top_build0(int argc,char** argv,struct sub_command* cmd) {
|
||||
if(cmd->name) {
|
||||
char* current=get_opt("program");
|
||||
char* current=get_opt("program",0);
|
||||
current=cat(current?current:"","(:",cmd->name,")",NULL);
|
||||
set_opt(&local_opt,"program",current,0);
|
||||
}
|
||||
|
|
@ -199,7 +199,7 @@ int opt_top_build0(int argc,char** argv,struct sub_command* cmd) {
|
|||
|
||||
int opt_top_build(int argc,char** argv,struct sub_command* cmd) {
|
||||
if(cmd->name && argc>1) {
|
||||
char* current=get_opt("program");
|
||||
char* current=get_opt("program",0);
|
||||
char* escaped=escape_string(argv[1]);
|
||||
int len=strlen(escaped)+strlen(cmd->name)+7;
|
||||
current=cat(current?current:"","(:",cmd->name," \"",escaped,"\")",NULL);
|
||||
|
|
@ -211,7 +211,7 @@ int opt_top_build(int argc,char** argv,struct sub_command* cmd) {
|
|||
|
||||
int opt_restart_after(int argc,char** argv,struct sub_command* cmd) {
|
||||
if(cmd->name && argc>1) {
|
||||
char* current=get_opt("restart");
|
||||
char* current=get_opt("restart",0);
|
||||
char* escaped=escape_string(argv[1]);
|
||||
int len=strlen(escaped)+strlen(cmd->name)+7;
|
||||
current=cat(current?current:"","(:",cmd->name," \"",escaped,"\")",NULL);
|
||||
|
|
@ -223,7 +223,7 @@ int opt_restart_after(int argc,char** argv,struct sub_command* cmd) {
|
|||
|
||||
int opt_final(int argc,char** argv,struct sub_command* cmd) {
|
||||
if(cmd->name && argc>1) {
|
||||
char* current=get_opt("final");
|
||||
char* current=get_opt("final",0);
|
||||
char* escaped=escape_string(argv[1]);
|
||||
int len=strlen(escaped)+strlen(cmd->name)+7;
|
||||
current=cat(current?current:"","(:",cmd->name," \"",escaped,"\")",NULL);
|
||||
|
|
@ -312,7 +312,7 @@ int main (int argc,char **argv) {
|
|||
proccmd(1,tmp,top_options,top_commands);
|
||||
}else
|
||||
for(i=1;i<argc;i+=proccmd(argc-i,&argv[i],top_options,top_commands));
|
||||
if(get_opt("program")) {
|
||||
if(get_opt("program",0)) {
|
||||
char* tmp[]={"run","-q","--"};
|
||||
proccmd(3,tmp,top_options,top_commands);
|
||||
}
|
||||
|
|
|
|||
16
src/opt.c
16
src/opt.c
|
|
@ -161,12 +161,22 @@ char* _get_opt(struct opts* opt,const char* name)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
char* get_opt(const char* name)
|
||||
char* _getenv(const char* name)
|
||||
{
|
||||
char* name_=substitute_char('_','.',q(name));
|
||||
char* ret=getenv(name_);
|
||||
s(name_);
|
||||
return ret;
|
||||
}
|
||||
|
||||
char* get_opt(const char* name,int env)
|
||||
{
|
||||
char* ret=NULL;
|
||||
ret=_get_opt(local_opt,name);
|
||||
if(env)ret=_getenv(name);
|
||||
if(!ret) {
|
||||
ret=_get_opt(global_opt,name);
|
||||
ret=_get_opt(local_opt,name);
|
||||
if(!ret)
|
||||
ret=_get_opt(global_opt,name);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ struct opts* load_opts(const char* path);
|
|||
int save_opts(const char* path,struct opts* opt);
|
||||
int set_opt(struct opts** opts,const char* name,char* value,int type);
|
||||
int unset_opt(struct opts** opts,const char* name);
|
||||
char* get_opt(const char* name);
|
||||
char* get_opt(const char* name,int env);
|
||||
void print_opts(struct opts* opt);
|
||||
char* sexp_opts(struct opts* opt);
|
||||
void free_opts(struct opts* opt);
|
||||
|
|
|
|||
|
|
@ -89,6 +89,7 @@ char* subseq(char* base,int beg,int end);
|
|||
char* remove_char(char* items,char* orig);
|
||||
int position_char(char* items,char* seq);
|
||||
int position_char_not(char* items,char* seq);
|
||||
char* substitute_char(char new,char old,char* seq);
|
||||
char* upcase(char* orig);
|
||||
char* downcase(char* orig);
|
||||
char* append_trail_slash(char* str);
|
||||
|
|
|
|||
Loading…
Reference in a new issue