Compare commits
3 Commits
0140f768cf
...
907e0c1832
| Author | SHA1 | Date | |
|---|---|---|---|
| 907e0c1832 | |||
| b8a5bd7338 | |||
| c68b1d2b26 |
@@ -144,7 +144,7 @@ static enum bshell_status process_record(
|
||||
}
|
||||
|
||||
fx_string *record = fx_string_create_from_cstr(
|
||||
fx_stringstream_ptr(cmd_p->cmd_tmp));
|
||||
fx_stringstream_get_cstr(cmd_p->cmd_tmp));
|
||||
bshell_pipeline_write_value(
|
||||
pipeline,
|
||||
FX_VALUE_OBJECT(record),
|
||||
|
||||
@@ -347,7 +347,7 @@ enum bshell_status bshell_table_ctx_print_record(
|
||||
}
|
||||
|
||||
size_t to_write = fx_stringstream_get_length(strm);
|
||||
const char *s = fx_stringstream_ptr(strm);
|
||||
const char *s = fx_stringstream_get_cstr(strm);
|
||||
bool overflow = false;
|
||||
if (to_write > c->col_width) {
|
||||
to_write = c->col_width - 2;
|
||||
|
||||
@@ -140,7 +140,7 @@ static bshell_command *resolve_native_command_local(
|
||||
}
|
||||
|
||||
bshell_command *result
|
||||
= bshell_native_command_create(fx_path_ptr(cmd_path));
|
||||
= bshell_native_command_create(fx_path_get_cstr(cmd_path));
|
||||
fx_path_unref(cmd_path);
|
||||
return result;
|
||||
}
|
||||
@@ -171,19 +171,16 @@ static bshell_command *resolve_native_command(
|
||||
fx_foreach(v, it)
|
||||
{
|
||||
const char *tok = NULL;
|
||||
fx_value_get_cstr(v, &tok);
|
||||
|
||||
fx_path *dir_path = fx_path_create_from_cstr(tok);
|
||||
const fx_path *parts[] = {dir_path, cmd_name_path};
|
||||
fx_path *full_path
|
||||
= fx_path_join(parts, sizeof parts / sizeof parts[0]);
|
||||
fx_path_unref(dir_path);
|
||||
= fx_path_join_list(2, v, &FX_VALUE_OBJECT(cmd_name));
|
||||
if (!fx_path_is_file(full_path)) {
|
||||
fx_path_unref(full_path);
|
||||
continue;
|
||||
}
|
||||
|
||||
result = bshell_native_command_create(fx_path_ptr(full_path));
|
||||
result = bshell_native_command_create(
|
||||
fx_path_get_cstr(full_path));
|
||||
fx_path_unref(full_path);
|
||||
break;
|
||||
}
|
||||
@@ -254,8 +251,8 @@ static enum bshell_status process_args(struct bshell_cmdcall_p *cmdcall)
|
||||
for (i32 i = cmdcall->cmd_args.count - 1; i >= 0; i--) {
|
||||
fx_stringstream_reset(str);
|
||||
fx_value_to_string(&cmdcall->cmd_args.items[i], str, NULL);
|
||||
fx_string *arg_str
|
||||
= fx_string_create_from_cstr(fx_stringstream_ptr(str));
|
||||
fx_string *arg_str = fx_string_create_from_cstr(
|
||||
fx_stringstream_get_cstr(str));
|
||||
fx_array_push_back(
|
||||
cmdcall->cmd_args_processed,
|
||||
FX_VALUE_OBJECT(arg_str));
|
||||
|
||||
@@ -220,7 +220,7 @@ static enum bshell_status eval_instruction(
|
||||
fx_value_unset(&y);
|
||||
|
||||
const fx_property *prop
|
||||
= fx_type_get_property(ty, fx_stringstream_ptr(strm));
|
||||
= fx_type_get_property(ty, fx_stringstream_get_cstr(strm));
|
||||
fx_stringstream_unref(strm);
|
||||
|
||||
if (!prop) {
|
||||
@@ -267,7 +267,7 @@ static enum bshell_status eval_instruction(
|
||||
fx_value_to_string(&x, strm, NULL);
|
||||
fx_string_prepend_cstr(
|
||||
result,
|
||||
fx_stringstream_ptr(strm));
|
||||
fx_stringstream_get_cstr(strm));
|
||||
fx_value_unset(&x);
|
||||
arg--;
|
||||
}
|
||||
|
||||
+5
-4
@@ -190,9 +190,10 @@ static fx_path *create_path(const char *dir_path, const char *script_path)
|
||||
return paths[1];
|
||||
}
|
||||
|
||||
fx_path *result = fx_path_join(
|
||||
(const fx_path **)paths,
|
||||
sizeof paths / sizeof paths[0]);
|
||||
fx_path *result = fx_path_join_list(
|
||||
2,
|
||||
&FX_CSTR(dir_path),
|
||||
&FX_CSTR(script_path));
|
||||
fx_path_unref(paths[0]);
|
||||
fx_path_unref(paths[1]);
|
||||
|
||||
@@ -210,7 +211,7 @@ enum bshell_status frontend_eval_file(
|
||||
}
|
||||
|
||||
struct bshell_file *file = NULL;
|
||||
ctx->ctx_status = bshell_file_open(fx_path_ptr(path), &file);
|
||||
ctx->ctx_status = bshell_file_open(fx_path_get_cstr(path), &file);
|
||||
fx_path_unref(path);
|
||||
|
||||
if (!FX_OK(ctx->ctx_status)) {
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <bshell/parse/token.h>
|
||||
#include <bshell/verb.h>
|
||||
#include <fx/cmdline/cmd.h>
|
||||
#include <fx/io/path.h>
|
||||
#include <stdio.h>
|
||||
|
||||
enum {
|
||||
@@ -83,6 +84,30 @@ static int bshell(
|
||||
frontend_init(&ctx, flags);
|
||||
enum bshell_status status = BSHELL_SUCCESS;
|
||||
|
||||
fx_path *config_base_dir = fx_path_get_system(FX_PATH_CONFIG);
|
||||
fx_path *profile_path = fx_path_join_list(
|
||||
3,
|
||||
&FX_VALUE_OBJECT(config_base_dir),
|
||||
&FX_CSTR("bshell"),
|
||||
&FX_CSTR("profile.bshell"));
|
||||
fx_path_unref(config_base_dir);
|
||||
|
||||
if (fx_path_is_file(profile_path)) {
|
||||
status = frontend_eval_file(
|
||||
&ctx,
|
||||
NULL,
|
||||
fx_path_get_cstr(profile_path));
|
||||
|
||||
if (status != BSHELL_SUCCESS) {
|
||||
fprintf(stderr,
|
||||
"%s: cannot evaluate '%s': %s\n",
|
||||
exec_name,
|
||||
fx_path_get_cstr(profile_path),
|
||||
bshell_status_get_description(status));
|
||||
}
|
||||
}
|
||||
fx_path_unref(profile_path);
|
||||
|
||||
size_t nr_input_files = fx_arglist_get_count(
|
||||
opt,
|
||||
FX_COMMAND_INVALID_ID,
|
||||
|
||||
Reference in New Issue
Block a user