New command -sh_style_result
This commit is contained in:
parent
76cd101944
commit
aa51bde75c
@ -276,6 +276,7 @@ Xorriso_option_setfacl_listi;
|
||||
Xorriso_option_setfattri;
|
||||
Xorriso_option_setfattr_listi;
|
||||
Xorriso_option_set_filter;
|
||||
Xorriso_option_sh_style_result;
|
||||
Xorriso_option_signal_handling;
|
||||
Xorriso_option_sleep;
|
||||
Xorriso_option_speed;
|
||||
|
@ -295,6 +295,7 @@ int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag)
|
||||
m->do_strict_acl= 0;
|
||||
m->dialog= 0;
|
||||
m->bsl_interpretation= 0;
|
||||
m->sh_style_result= 0;
|
||||
m->search_mode= 0;
|
||||
m->structured_search= 1;
|
||||
m->do_iso_rr_pattern= 1;
|
||||
|
@ -544,9 +544,12 @@ revoke_sorting:;
|
||||
report_size= sub_size/1024;
|
||||
if(report_size*1024<sub_size)
|
||||
report_size++;
|
||||
sprintf(xorriso->result_line, "%7.f ",(double) (report_size));
|
||||
if(xorriso->sh_style_result)
|
||||
sprintf(xorriso->result_line, "%-7.f ",(double) (report_size));
|
||||
else
|
||||
sprintf(xorriso->result_line, "%7.f ",(double) (report_size));
|
||||
sprintf(xorriso->result_line+strlen(xorriso->result_line), "%s\n",
|
||||
Text_shellsafe(show_path, sfe, 0));
|
||||
Xorriso_esc_filepath(xorriso,show_path, sfe, 0));
|
||||
Xorriso_result(xorriso, 0);
|
||||
}
|
||||
|
||||
@ -848,7 +851,7 @@ int Xorriso_lsx_filev(struct XorrisO *xorriso, char *wd,
|
||||
if(filec>1) {
|
||||
strcpy(xorriso->result_line, "\n");
|
||||
Xorriso_result(xorriso,0);
|
||||
Text_shellsafe(filev[i], xorriso->result_line, 0);
|
||||
Xorriso_esc_filepath(xorriso,filev[i], xorriso->result_line, 0);
|
||||
strcat(xorriso->result_line, ":\n");
|
||||
Xorriso_result(xorriso,0);
|
||||
}
|
||||
@ -894,14 +897,17 @@ int Xorriso_lsx_filev(struct XorrisO *xorriso, char *wd,
|
||||
if(ret==0)
|
||||
continue;
|
||||
}
|
||||
sprintf(rpt, "%7.f ",(double) (size/1024));
|
||||
if(xorriso->sh_style_result)
|
||||
sprintf(rpt, "%-7.f ",(double) (size/1024));
|
||||
else
|
||||
sprintf(rpt, "%7.f ",(double) (size/1024));
|
||||
}
|
||||
if(link_target[0]) {
|
||||
Text_shellsafe(filev[i], xorriso->result_line, 1);
|
||||
Xorriso_esc_filepath(xorriso,filev[i], xorriso->result_line, 1);
|
||||
strcat(xorriso->result_line, " -> ");
|
||||
Text_shellsafe(link_target, xorriso->result_line, 1 | 2);
|
||||
Xorriso_esc_filepath(xorriso,link_target, xorriso->result_line, 1 | 2);
|
||||
} else {
|
||||
Text_shellsafe(filev[i], xorriso->result_line, 1);
|
||||
Xorriso_esc_filepath(xorriso,filev[i], xorriso->result_line, 1);
|
||||
}
|
||||
strcat(xorriso->result_line, "\n");
|
||||
Xorriso_result(xorriso, 0);
|
||||
@ -1225,7 +1231,7 @@ int Xorriso_findx_action(struct XorrisO *xorriso, struct FindjoB *job,
|
||||
} else if(action == 44) { /* list_extattr */
|
||||
ret= Xorriso_list_extattr(xorriso, NULL, abs_path, show_path, target, 2);
|
||||
} else {
|
||||
Text_shellsafe(show_path, xorriso->result_line, 0);
|
||||
Xorriso_esc_filepath(xorriso,show_path, xorriso->result_line, 0);
|
||||
strcat(xorriso->result_line, "\n");
|
||||
Xorriso_result(xorriso, 0);
|
||||
ret= 1;
|
||||
|
@ -2676,7 +2676,7 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job,
|
||||
ret= 1;
|
||||
|
||||
} else { /* includes : 15 in_iso */
|
||||
Text_shellsafe(show_path, xorriso->result_line, 0);
|
||||
Xorriso_esc_filepath(xorriso, show_path, xorriso->result_line, 0);
|
||||
strcat(xorriso->result_line, "\n");
|
||||
Xorriso_result(xorriso, 0);
|
||||
ret= 1;
|
||||
|
@ -1448,9 +1448,12 @@ much_too_long:;
|
||||
report_size= sub_size/1024;
|
||||
if(report_size*1024<sub_size)
|
||||
report_size++;
|
||||
sprintf(xorriso->result_line, "%7.f ",(double) (report_size));
|
||||
if(xorriso->sh_style_result)
|
||||
sprintf(xorriso->result_line, "%-7.f ",(double) (report_size));
|
||||
else
|
||||
sprintf(xorriso->result_line, "%7.f ",(double) (report_size));
|
||||
sprintf(xorriso->result_line+strlen(xorriso->result_line), "%s\n",
|
||||
Text_shellsafe(show_path, sfe, 0));
|
||||
Xorriso_esc_filepath(xorriso, show_path, sfe, 0));
|
||||
Xorriso_result(xorriso, 0);
|
||||
}
|
||||
ret= 1;
|
||||
@ -1621,7 +1624,7 @@ int Xorriso_ls_filev(struct XorrisO *xorriso, char *wd,
|
||||
if(filec>1) {
|
||||
strcpy(xorriso->result_line, "\n");
|
||||
Xorriso_result(xorriso,0);
|
||||
Text_shellsafe(filev[i], xorriso->result_line, 0);
|
||||
Xorriso_esc_filepath(xorriso, filev[i], xorriso->result_line, 0);
|
||||
strcat(xorriso->result_line, ":\n");
|
||||
Xorriso_result(xorriso,0);
|
||||
}
|
||||
@ -1670,14 +1673,17 @@ int Xorriso_ls_filev(struct XorrisO *xorriso, char *wd,
|
||||
if(ret==0)
|
||||
continue;
|
||||
}
|
||||
sprintf(rpt, "%7.f ",(double) (size/1024));
|
||||
if(xorriso->sh_style_result)
|
||||
sprintf(rpt, "%-7.f ",(double) (size/1024));
|
||||
else
|
||||
sprintf(rpt, "%7.f ",(double) (size/1024));
|
||||
}
|
||||
if(link_target[0] && (flag&5)==1) {
|
||||
Text_shellsafe(filev[i], xorriso->result_line, 1),
|
||||
Xorriso_esc_filepath(xorriso, filev[i], xorriso->result_line, 1),
|
||||
strcat(xorriso->result_line, " -> ");
|
||||
Text_shellsafe(link_target, xorriso->result_line, 1 | 2);
|
||||
Xorriso_esc_filepath(xorriso, link_target, xorriso->result_line, 1 | 2);
|
||||
} else {
|
||||
Text_shellsafe(filev[i], xorriso->result_line, 1);
|
||||
Xorriso_esc_filepath(xorriso, filev[i], xorriso->result_line, 1);
|
||||
}
|
||||
strcat(xorriso->result_line, "\n");
|
||||
Xorriso_result(xorriso, 0);
|
||||
@ -1783,11 +1789,11 @@ cannot_create_iter:;
|
||||
continue;
|
||||
}
|
||||
if(link_target[0] && (flag&1)) {
|
||||
Text_shellsafe(npt, xorriso->result_line, 1);
|
||||
Xorriso_esc_filepath(xorriso, npt, xorriso->result_line, 1);
|
||||
strcat(xorriso->result_line, " -> ");
|
||||
Text_shellsafe(link_target, xorriso->result_line, 1 | 2);
|
||||
Xorriso_esc_filepath(xorriso, link_target, xorriso->result_line, 1 | 2);
|
||||
} else {
|
||||
Text_shellsafe(npt, xorriso->result_line, 1);
|
||||
Xorriso_esc_filepath(xorriso, npt, xorriso->result_line, 1);
|
||||
}
|
||||
strcat(xorriso->result_line, "\n");
|
||||
Xorriso_result(xorriso, 0);
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
/* xorriso - creates, loads, manipulates and burns ISO 9660 filesystem images.
|
||||
|
||||
Copyright 2007-2012 Thomas Schmitt, <scdbackup@gmx.net>
|
||||
Copyright 2007-2013 Thomas Schmitt, <scdbackup@gmx.net>
|
||||
|
||||
Provided under GPL version 2 or later.
|
||||
|
||||
@ -1209,8 +1209,10 @@ int Xorriso_option_cdi(struct XorrisO *xorriso, char *iso_rr_path, int flag)
|
||||
Xorriso_warn_of_wildcards(xorriso, iso_rr_path, 1);
|
||||
sprintf(xorriso->info_text,"previous working directory:\n");
|
||||
Xorriso_info(xorriso,0);
|
||||
Text_shellsafe(xorriso->wdi, xorriso->result_line, 0);
|
||||
strcat(xorriso->result_line, "/\n");
|
||||
Xorriso_esc_filepath(xorriso, xorriso->wdi, xorriso->result_line, 0);
|
||||
if(xorriso->sh_style_result == 0 || xorriso->wdi[0] == 0)
|
||||
strcat(xorriso->result_line, "/");
|
||||
strcat(xorriso->result_line, "\n");
|
||||
Xorriso_result(xorriso,0);
|
||||
if(strcmp(iso_rr_path,"/")==0 || iso_rr_path[0]==0) {
|
||||
strcpy(xorriso->wdi,"");
|
||||
@ -1270,8 +1272,10 @@ int Xorriso_option_cdx(struct XorrisO *xorriso, char *disk_path, int flag)
|
||||
Xorriso_warn_of_wildcards(xorriso, disk_path, 1|2);
|
||||
sprintf(xorriso->info_text,"previous working directory on hard disk:\n");
|
||||
Xorriso_info(xorriso,0);
|
||||
Text_shellsafe(xorriso->wdx, xorriso->result_line, 0);
|
||||
strcat(xorriso->result_line, "/\n");
|
||||
Xorriso_esc_filepath(xorriso, xorriso->wdx, xorriso->result_line, 0);
|
||||
if(xorriso->sh_style_result == 0 || xorriso->wdx[0] == 0)
|
||||
strcat(xorriso->result_line, "/");
|
||||
strcat(xorriso->result_line, "\n");
|
||||
Xorriso_result(xorriso,0);
|
||||
if(strcmp(disk_path,"/")==0) {
|
||||
strcpy(xorriso->wdx,"");
|
||||
|
@ -416,8 +416,10 @@ int Xorriso_option_pwdi(struct XorrisO *xorriso, int flag)
|
||||
{
|
||||
sprintf(xorriso->info_text,"current working directory in ISO image:\n");
|
||||
Xorriso_info(xorriso,0);
|
||||
Text_shellsafe(xorriso->wdi, xorriso->result_line, 0);
|
||||
strcat(xorriso->result_line, "/\n");
|
||||
Xorriso_esc_filepath(xorriso, xorriso->wdi, xorriso->result_line, 0);
|
||||
if(xorriso->sh_style_result == 0 || xorriso->wdi[0] == 0)
|
||||
strcat(xorriso->result_line, "/");
|
||||
strcat(xorriso->result_line, "\n");
|
||||
Xorriso_result(xorriso,0);
|
||||
return(1);
|
||||
}
|
||||
@ -428,7 +430,10 @@ int Xorriso_option_pwdx(struct XorrisO *xorriso, int flag)
|
||||
{
|
||||
sprintf(xorriso->info_text,"current working directory on hard disk:\n");
|
||||
Xorriso_info(xorriso,0);
|
||||
sprintf(xorriso->result_line,"%s/\n",xorriso->wdx);
|
||||
Xorriso_esc_filepath(xorriso, xorriso->wdx, xorriso->result_line, 0);
|
||||
if(xorriso->sh_style_result == 0 || xorriso->wdx[0] == 0)
|
||||
strcat(xorriso->result_line, "/");
|
||||
strcat(xorriso->result_line, "\n");
|
||||
Xorriso_result(xorriso,0);
|
||||
return(1);
|
||||
}
|
||||
@ -1223,6 +1228,23 @@ ex:;
|
||||
}
|
||||
|
||||
|
||||
/* Option -sh_style_result */
|
||||
int Xorriso_option_sh_style_result(struct XorrisO *xorriso, char *mode,
|
||||
int flag)
|
||||
{
|
||||
if(strcmp(mode, "off") == 0) {
|
||||
xorriso->sh_style_result= 0;
|
||||
} else if(strcmp(mode, "on") == 0) {
|
||||
xorriso->sh_style_result= 1;
|
||||
} else {
|
||||
sprintf(xorriso->info_text, "-sh_style_result: unknown mode '%s'", mode);
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
||||
return(0);
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
/* Option -signal_handling */
|
||||
/* @param flag bit0= prescan mode: do not yet install the eventual handler
|
||||
else: when switching from other modes to "off":
|
||||
|
@ -517,7 +517,7 @@ int Xorriso_count_args(struct XorrisO *xorriso, int argc, char **argv,
|
||||
"prog","prog_help","publisher","quoted_not_list","quoted_path_list",
|
||||
"reassure","report_about","rockridge",
|
||||
"rom_toc_scan","rr_reloc_dir","scsi_log",
|
||||
"session_log","signal_handling","sleep",
|
||||
"session_log","sh_style_result","signal_handling","sleep",
|
||||
"speed","split_size","status","status_history_max",
|
||||
"stdio_sync","stream_recording","system_id","temp_mem_limit","toc_of",
|
||||
"uid","unregister_filter","use_readline","volid","volset_id",
|
||||
@ -641,6 +641,7 @@ int Xorriso_cmd_sorting_rank(struct XorrisO *xorriso,
|
||||
"errfile_log", "session_log", "scsi_log",
|
||||
"options_from_file", "list_delimiter",
|
||||
"print", "print_info", "print_mark", "prompt", "sleep",
|
||||
"sh_style_result",
|
||||
|
||||
"* Drive and media related inquiry actions (1):",
|
||||
"devices", "device_links",
|
||||
@ -1704,6 +1705,10 @@ next_command:;
|
||||
ret= Xorriso_option_set_filter(xorriso, "", argc, argv, idx,
|
||||
(strcmp(cmd,"show_stream_r")==0) | 2 | 4);
|
||||
|
||||
} else if(strcmp(cmd,"sh_style_result")==0) {
|
||||
(*idx)++;
|
||||
ret= Xorriso_option_sh_style_result(xorriso, arg1, 0);
|
||||
|
||||
} else if(strcmp(cmd,"signal_handling")==0) {
|
||||
(*idx)++;
|
||||
ret= Xorriso_option_signal_handling(xorriso, arg1, 0);
|
||||
|
@ -2480,6 +2480,12 @@ int Xorriso_status(struct XorrisO *xorriso, char *filter, FILE *fp, int flag)
|
||||
if(!(is_default && no_defaults))
|
||||
Xorriso_status_result(xorriso,filter,fp,flag&2);
|
||||
|
||||
is_default= (xorriso->sh_style_result == 0);
|
||||
sprintf(line, "-sh_style_result %s\n",
|
||||
xorriso->sh_style_result ? "on" : "off");
|
||||
if(!(is_default && no_defaults))
|
||||
Xorriso_status_result(xorriso,filter,fp,flag&2);
|
||||
|
||||
is_default= (xorriso->bsl_interpretation == 0);
|
||||
strcpy(line, "-backslash_codes ");
|
||||
if(xorriso->bsl_interpretation == 0)
|
||||
@ -4119,3 +4125,29 @@ ex:;
|
||||
}
|
||||
|
||||
|
||||
/* @param flag bit0= append to out_text rather than overwrite it
|
||||
bit1= length limit is 10 * SfileadrL rather than 5 *
|
||||
*/
|
||||
char *Xorriso_esc_filepath(struct XorrisO *xorriso,
|
||||
char *in_text, char *out_text, int flag)
|
||||
{
|
||||
int l, w=0, limit= 5 * SfileadrL;
|
||||
char *res;
|
||||
|
||||
if(xorriso->sh_style_result == 0) {
|
||||
res= Text_shellsafe(in_text, out_text, flag);
|
||||
return(res);
|
||||
}
|
||||
if(flag&1)
|
||||
w= strlen(out_text);
|
||||
if(flag & 2)
|
||||
limit= 10 * SfileadrL;
|
||||
l= strlen(in_text);
|
||||
if(w + l >= limit) {
|
||||
strcpy(out_text, "'xorriso: TEXT MUCH TOO LONG ... ");
|
||||
return(out_text);
|
||||
}
|
||||
strcpy(out_text + w, in_text);
|
||||
return(out_text);
|
||||
}
|
||||
|
||||
|
@ -102,5 +102,8 @@ int Xorriso_launch_frontend(struct XorrisO *xorriso, int argc, char **argv,
|
||||
int Xorriso_named_pipe_loop(struct XorrisO *xorriso,
|
||||
char *pipe_paths[3], int flag);
|
||||
|
||||
char *Xorriso_esc_filepath(struct XorrisO *xorriso,
|
||||
char *in_text, char *out_text, int flag);
|
||||
|
||||
#endif /* ! Xorriso_pvt_textio_includeD */
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
.\" First parameter, NAME, should be all caps
|
||||
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
|
||||
.\" other parameters are allowed: see man(7), man(1)
|
||||
.TH XORRISO 1 "Version 1.3.1, Jun 29, 2013"
|
||||
.TH XORRISO 1 "Version 1.3.1, Jul 01, 2013"
|
||||
.\" Please adjust this date whenever revising the manpage.
|
||||
.\"
|
||||
.\" Some roff macros, for reference:
|
||||
@ -4423,6 +4423,18 @@ quotation marks.
|
||||
For brevity the list delimiter is referred as "\-\-"
|
||||
throughout this text.
|
||||
.TP
|
||||
\fB\-sh_style_result\fR "on"|"off"
|
||||
Make the result output of some filesystem inspection commands look more like
|
||||
the output of equivalent shell commands. The most important effect is to
|
||||
prevent the wrapping of file addresses into quotation marks with commands
|
||||
\-pwd \-pwdx \-ls \-lsd \-lsl \-lsdl \-lsx \-lsdx \-lslx \-lsdlx
|
||||
\-du \-dus \-dux \-dusx \-findx \-find
|
||||
.br
|
||||
This will make ambigous the representation of file names which contain
|
||||
newline characters. On the other hand it should facilitate integration
|
||||
of xorriso into shell scripts which already use the corresponding
|
||||
shell commands.
|
||||
.TP
|
||||
\fB\-backslash_codes\fR "on"|"off"|mode[:mode]
|
||||
Enable or disable the interpretation of symbolic representations of special
|
||||
characters with quoted input, or with program arguments, or with program
|
||||
|
@ -1664,6 +1664,7 @@ int Xorriso_option_mvi(struct XorrisO *xorriso, int argc, char **argv,
|
||||
int *idx, int flag);
|
||||
|
||||
/* Option -named_pipe_loop */
|
||||
/* @since 1.3.2 */
|
||||
int Xorriso_option_named_pipe_loop(struct XorrisO *xorriso, char *stdin_pipe,
|
||||
char *stdout_pipe, char *stderr_pipe,
|
||||
int flag);
|
||||
@ -1849,6 +1850,11 @@ int Xorriso_option_setfattr_listi(struct XorrisO *xorriso, char *path,
|
||||
int Xorriso_option_set_filter(struct XorrisO *xorriso, char *name,
|
||||
int argc, char **argv, int *idx, int flag);
|
||||
|
||||
/* Option -sh_style_result */
|
||||
/* @since 1.3.2 */
|
||||
int Xorriso_option_sh_style_result(struct XorrisO *xorriso, char *mode,
|
||||
int flag);
|
||||
|
||||
/* Command -signal_handling */
|
||||
/* @param flag bit0= do not yet install the eventual handler
|
||||
@since 1.1.0
|
||||
|
@ -3877,6 +3877,17 @@ File: xorriso.info, Node: Scripting, Next: Frontend, Prev: Emulation, Up: Co
|
||||
For brevity the list delimiter is referred as "--" throughout this
|
||||
text.
|
||||
|
||||
-sh_style_result "on"|"off"
|
||||
Make the result output of some filesystem inspection commands look
|
||||
more like the output of equivalent shell commands. The most
|
||||
important effect is to prevent the wrapping of file addresses into
|
||||
quotation marks with commands -pwd -pwdx -ls -lsd -lsl -lsdl
|
||||
-lsx -lsdx -lslx -lsdlx -du -dus -dux -dusx -findx -find
|
||||
This will make ambigous the representation of file names which
|
||||
contain newline characters. On the other hand it should facilitate
|
||||
integration of xorriso into shell scripts which already use the
|
||||
corresponding shell commands.
|
||||
|
||||
-backslash_codes "on"|"off"|mode[:mode]
|
||||
Enable or disable the interpretation of symbolic representations
|
||||
of special characters with quoted input, or with program
|
||||
@ -4753,7 +4764,7 @@ File: xorriso.info, Node: CommandIdx, Next: ConceptIdx, Prev: Legal, Up: Top
|
||||
|