Skip to content

Commit

Permalink
First stab at directory transition. Test with care...
Browse files Browse the repository at this point in the history
darcs-hash:20061019115023-ac50b-30c3fd51d8af8a616d63dfcac39370d7fe6d144e.gz
  • Loading branch information
liljencrantz committed Oct 19, 2006
1 parent 52b2525 commit ea998b0
Show file tree
Hide file tree
Showing 22 changed files with 904 additions and 565 deletions.
54 changes: 25 additions & 29 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ CFLAGS=@CFLAGS@ $(MACROS)
CPPFLAGS=@CPPFLAGS@
LDFLAGS= @LIBS@ @LDFLAGS@


#etc files to install
ETC_DIR_INSTALL = etc/fish_interactive.fish

# Set to 1 if we have gettext
HAVE_GETTEXT=@HAVE_GETTEXT@

Expand All @@ -71,6 +67,7 @@ FISH_OBJS := function.o builtin.o complete.o env.o exec.o \
sanity.o tokenizer.o wildcard.o wgetopt.o wutil.o input.o \
output.o intern.o env_universal.o env_universal_common.o \
input_common.o event.o signal.o io.o parse_util.o common.o screen.o\
path.o

# Additional files used by builtin.o
BUILTIN_FILES := builtin_help.c builtin_set.c builtin_commandline.c \
Expand Down Expand Up @@ -153,11 +150,11 @@ MAIN_DIR_FILES := Doxyfile Doxyfile.user Makefile.in configure \
main.c fish_pager.c fishd.c seq.in

# Files in ./etc/
ETC_DIR_FILES :=etc/fish.in etc/fish_inputrc \
etc/fish_interactive.fish.in
ETC_DIR_FILES :=etc/config.fish.in etc/fish_inputrc


# Files in ./share/
SHARE_DIR_FILES :=share/fish.in
SHARE_DIR_FILES :=share/config.fish.in share/config_interactive.fish.in

# Files in ./tests/
TESTS_DIR_FILES := $(TEST_IN) $(TEST_IN:.in=.out) $(TEST_IN:.in=.err) \
Expand Down Expand Up @@ -185,7 +182,7 @@ TRANSLATIONS_SRC := $(wildcard po/*.po)
TRANSLATIONS := $(TRANSLATIONS_SRC:.po=.gmo)

#Make everything needed for installing fish
all: $(PROGRAMS) user_doc etc/fish share/fish etc/fish_interactive.fish $(TRANSLATIONS)
all: $(PROGRAMS) user_doc etc/config.fish share/config.fish share/config_interactive.fish $(TRANSLATIONS)
@echo fish has now been built.
@echo Use \'make install\' to install fish.
.PHONY: all
Expand Down Expand Up @@ -409,22 +406,20 @@ install-force: all install-translations
for i in $(PROGRAMS); do\
$(INSTALL) -m 755 $$i $(DESTDIR)$(bindir) ; \
done;
$(INSTALL) -m 755 -d $(DESTDIR)$(sysconfdir)/fish.d
$(INSTALL) -m 755 -d $(DESTDIR)$(sysconfdir)/fish
$(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish
$(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/completions
$(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/functions
$(INSTALL) -m 644 etc/fish $(DESTDIR)$(sysconfdir)/fish
$(INSTALL) -m 644 share/fish $(DESTDIR)$(datadir)/fish
for i in $(ETC_DIR_INSTALL); do \
$(INSTALL) -m 644 $$i $(DESTDIR)$(sysconfdir)/fish.d; \
done;
$(INSTALL) -m 644 etc/config.fish $(DESTDIR)$(sysconfdir)/fish/
$(INSTALL) -m 644 share/config.fish $(DESTDIR)$(datadir)/fish/
$(INSTALL) -m 644 share/config_interactive.fish $(DESTDIR)$(datadir)/fish/
for i in $(COMPLETIONS_DIR_FILES); do \
$(INSTALL) -m 644 $$i $(DESTDIR)$(datadir)/fish/completions/; \
done;
for i in $(FUNCTIONS_DIR_FILES); do \
$(INSTALL) -m 644 $$i $(DESTDIR)$(datadir)/fish/functions/; \
done;
$(INSTALL) -m 644 etc/fish_inputrc $(DESTDIR)$(sysconfdir)/fish_inputrc;
$(INSTALL) -m 644 etc/fish_inputrc $(DESTDIR)$(sysconfdir)/fish/fish_inputrc;
$(INSTALL) -m 755 -d $(DESTDIR)$(docdir)
for i in user_doc/html/* ChangeLog; do \
if test -f $$i; then \
Expand Down Expand Up @@ -453,11 +448,9 @@ uninstall: uninstall-translations
rm -f $(DESTDIR)$(bindir)/$$i; \
done;
rm -f $(DESTDIR)$(bindir)/xsel
rm -f $(DESTDIR)$(sysconfdir)/fish
rm -f $(DESTDIR)$(sysconfdir)/fish_inputrc
if test -f $(DESTDIR)$(sysconfdir)/fish.d/fish_interactive.fish; then \
rm -f $(DESTDIR)$(sysconfdir)/fish.d/fish_interactive.fish; \
fi
rm -f $(DESTDIR)$(sysconfdir)/fish/config.fish
rm -f $(DESTDIR)$(sysconfdir)/fish/fish_inputrc
rmdir $(DESTDIR)$(sysconfdir)/fish; true
if test -d $(DESTDIR)$(datadir)/fish; then \
rm -r $(DESTDIR)$(datadir)/fish; \
fi
Expand Down Expand Up @@ -533,7 +526,7 @@ count: count.o
$(CC) count.o -o $@

set_color: set_color.o doc_src/set_color.o common.o
$(CC) set_color.o doc_src/set_color.o common.o $(LDFLAGS) -o $@
$(CC) set_color.o doc_src/set_color.o common.o wutil.o $(LDFLAGS) -o $@

# Test program for the tokenizer library
tokenizer_test: tokenizer.c tokenizer.h wutil.o common.o
Expand Down Expand Up @@ -638,7 +631,7 @@ clean:
builtin.o: config.h fallback.h util.h wutil.h builtin.h function.h complete.h
builtin.o: proc.h io.h parser.h event.h reader.h env.h common.h wgetopt.h
builtin.o: sanity.h tokenizer.h wildcard.h input_common.h input.h intern.h
builtin.o: signal.h halloc.h halloc_util.h parse_util.h expand.h
builtin.o: signal.h halloc.h halloc_util.h parse_util.h expand.h path.h
builtin.o: builtin_help.c builtin_set.c builtin_commandline.c
builtin.o: builtin_complete.c builtin_ulimit.c builtin_jobs.c
builtin_commandline.o: config.h signal.h fallback.h util.h wutil.h builtin.h
Expand All @@ -660,7 +653,7 @@ common.o: fallback.c
complete.o: config.h signal.h fallback.h util.h tokenizer.h wildcard.h proc.h
complete.o: io.h parser.h event.h function.h complete.h builtin.h env.h
complete.o: exec.h expand.h common.h reader.h history.h intern.h parse_util.h
complete.o: halloc.h halloc_util.h wutil.h
complete.o: halloc.h halloc_util.h wutil.h path.h
count.o: config.h
env.o: config.h signal.h fallback.h util.h wutil.h proc.h io.h common.h env.h
env.o: sanity.h expand.h history.h reader.h parser.h event.h env_universal.h
Expand All @@ -680,14 +673,13 @@ expand.o: io.h parser.h event.h expand.h wildcard.h exec.h tokenizer.h
expand.o: complete.h parse_util.h halloc.h halloc_util.h
fallback.o: config.h fallback.h util.h
fishd.o: config.h signal.h fallback.h util.h common.h wutil.h
fishd.o: env_universal_common.h
fishd.o: env_universal_common.h halloc.h halloc_util.h path.h
fish_pager.o: config.h signal.h fallback.h util.h wutil.h common.h complete.h
fish_pager.o: output.h input_common.h env_universal.h env_universal_common.h
fish_pager.o: halloc.h halloc_util.h
fish_tests.o: config.h signal.h fallback.h util.h common.h proc.h io.h
fish_tests.o: reader.h builtin.h function.h complete.h wutil.h env.h expand.h
fish_tests.o: parser.h event.h tokenizer.h output.h exec.h halloc_util.h
foo.o: config.h signal.h
function.o: config.h signal.h wutil.h fallback.h util.h function.h proc.h
function.o: io.h parser.h event.h common.h intern.h reader.h parse_util.h
function.o: env.h expand.h
Expand All @@ -696,9 +688,9 @@ halloc_util.o: config.h fallback.h util.h common.h halloc.h
highlight.o: config.h signal.h fallback.h util.h wutil.h highlight.h
highlight.o: tokenizer.h proc.h io.h parser.h event.h parse_util.h builtin.h
highlight.o: function.h env.h expand.h sanity.h common.h complete.h output.h
highlight.o: halloc.h halloc_util.h wildcard.h
highlight.o: halloc.h halloc_util.h wildcard.h path.h
history.o: config.h fallback.h util.h wutil.h history.h common.h reader.h
history.o: env.h sanity.h signal.h halloc.h halloc_util.h
history.o: env.h sanity.h signal.h halloc.h halloc_util.h path.h
input.o: config.h signal.h fallback.h util.h wutil.h reader.h proc.h io.h
input.o: common.h sanity.h input_common.h input.h parser.h event.h env.h
input.o: expand.h output.h intern.h
Expand All @@ -708,20 +700,24 @@ intern.o: config.h fallback.h util.h wutil.h common.h intern.h
io.o: config.h fallback.h util.h wutil.h exec.h proc.h io.h common.h halloc.h
key_reader.o: config.h fallback.h input_common.h
kill.o: config.h signal.h fallback.h util.h wutil.h kill.h proc.h io.h
kill.o: sanity.h common.h env.h exec.h parser.h event.h halloc.h
kill.o: sanity.h common.h env.h exec.h halloc.h path.h
main.o: config.h signal.h fallback.h util.h common.h reader.h builtin.h
main.o: function.h complete.h wutil.h env.h sanity.h proc.h io.h parser.h
main.o: event.h expand.h intern.h exec.h output.h halloc_util.h history.h
main.o: event.h expand.h intern.h exec.h output.h halloc.h halloc_util.h
main.o: history.h path.h
mimedb.o: config.h xdgmime.h fallback.h util.h
output.o: config.h signal.h fallback.h util.h wutil.h expand.h common.h
output.o: output.h halloc_util.h highlight.h
parser.o: config.h signal.h fallback.h util.h common.h wutil.h proc.h io.h
parser.o: parser.h event.h tokenizer.h exec.h wildcard.h function.h builtin.h
parser.o: env.h expand.h reader.h sanity.h env_universal.h
parser.o: env_universal_common.h intern.h parse_util.h halloc.h halloc_util.h
parser.o: path.h
parse_util.o: config.h fallback.h util.h wutil.h common.h tokenizer.h
parse_util.o: parse_util.h expand.h intern.h exec.h proc.h io.h env.h
parse_util.o: wildcard.h halloc_util.h
path.o: config.h fallback.h util.h common.h env.h wutil.h halloc.h
path.o: halloc_util.h path.h expand.h
proc.o: config.h signal.h fallback.h util.h wutil.h proc.h io.h common.h
proc.o: reader.h sanity.h env.h parser.h event.h halloc.h halloc_util.h
proc.o: output.h
Expand Down
3 changes: 2 additions & 1 deletion builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
#include "halloc_util.h"
#include "parse_util.h"
#include "expand.h"
#include "path.h"



Expand Down Expand Up @@ -2076,7 +2077,7 @@ static int builtin_cd( wchar_t **argv )
else
dir_in = argv[1];

dir = parser_cdpath_get( context, dir_in );
dir = path_get_cdpath( context, dir_in );

if( !dir )
{
Expand Down
39 changes: 39 additions & 0 deletions common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1557,3 +1557,42 @@ void tokenize_variable_array( const wchar_t *val, array_list_t *out )
}


int create_directory( wchar_t *d )
{
int ok = 0;
struct stat buf;
int stat_res = 0;

while( (stat_res = wstat(d, &buf ) ) != 0 )
{
if( errno != EAGAIN )
break;
}

if( stat_res == 0 )
{
if( S_ISDIR( buf.st_mode ) )
{
ok = 1;
}
}
else
{
if( errno == ENOENT )
{
wchar_t *dir = wcsdup( d );
dir = wdirname( dir );
if( !create_directory( dir ) )
{
if( !wmkdir( d, 0700 ) )
{
ok = 1;
}
}
free(dir);
}
}

return ok?0:-1;
}

7 changes: 7 additions & 0 deletions common.h
Original file line number Diff line number Diff line change
Expand Up @@ -358,5 +358,12 @@ void write_screen( const wchar_t *msg, string_buffer_t *buff );
void tokenize_variable_array( const wchar_t *val, array_list_t *out );


/**
Make sure the specified direcotry exists. If no, try to create it.
\return 0 if the directory exists, -1 otherwise.
*/
int create_directory( wchar_t *d );

#endif

5 changes: 3 additions & 2 deletions complete.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include "halloc.h"
#include "halloc_util.h"
#include "wutil.h"
#include "path.h"


/*
Expand Down Expand Up @@ -407,7 +408,7 @@ void complete_add( const wchar_t *cmd,
complete_entry_opt *opt;

CHECK( cmd, );

complete_init();

c = complete_find_exact_entry( cmd, cmd_type );
Expand Down Expand Up @@ -581,7 +582,7 @@ static void parse_cmd_string( void *context,
wchar_t *cmd, *path;

/* Get the path of the command */
path = parser_get_filename( context, str );
path = path_get_path( context, str );
if( path == 0 )
{
/**
Expand Down
41 changes: 22 additions & 19 deletions doc_src/doc.hdr
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ automatically loaded when needed. A function definition file must have
a filename consisting of the name of the function plus the suffix
'.fish'.

The default value for \$fish_function_path is \c ~/.fish.d/functions
\c /etc/fish.d/functions \c /usr/share/fish/functions. The exact path
The default value for \$fish_function_path is \c ~/.config/fish/functions
\c /etc/fish/functions \c /usr/share/fish/functions. The exact path
to the last two of these may be slighly different depending on what
install path prefix was chosen at configuration time. The rationale
behind having three different directories is that the first one is for
Expand Down Expand Up @@ -404,8 +404,8 @@ searches through any directories in the array variable
loaded when needed. A completion file must have a filename consisting
of the name of the command to complete and the suffix '.fish'.

The default value for \$fish_complete_path is ~/.fish.d/completions,
/etc/fish.d/completions and /usr/share/fish/completions. The exact
The default value for \$fish_complete_path is ~/.config/fish/completions,
/etc/fish/completions and /usr/share/fish/completions. The exact
path to the last two of these may be slighly different depending on
what install path prefix was chosen at configuration time. If a
suitable file is found in one of these directories, it will be
Expand Down Expand Up @@ -972,8 +972,8 @@ Here are some of the commands available in the editor:
- Alt-p adds the string '| less;' to the end of the job under the cursor. The result is that the output of the command will be paged.

You can change these key bindings by making an inputrc file. To do
this, copy the file /etc/fish_inputrc to your home directory and
rename it to '.fish_inputrc'. Now you can edit the file .fish_inputrc,
this, copy the file /etc/fish/fish_inputrc to your home directory and
rename it to '.config/fish/fish_inputrc'. Now you can edit the file
to change your key bindings. The fileformat of this file is described
in the manual page for readline. Use the command <code>man readline</code>
to read up on this syntax. Please note that the list of key binding
Expand Down Expand Up @@ -1041,7 +1041,7 @@ cursor when the search began.

History searches can be aborted by pressing the escape key.

The history is stored in the file '.fish_history'. It is automatically
The history is stored in the file '~/.config/fish/fish_history'. It is automatically
read on startup and merged on program exit.

Example:
Expand All @@ -1065,20 +1065,23 @@ which the user can change <code>fish</code>'s behaviour.

\section initialization Initialization files

On startup, \c fish evaluates the files /usr/share/fish/fish,
/etc/fish (Or ~/etc/fish if you installed fish in your home directory)
and ~/.fish, in that order. The first file should not be directly
edited, the second one is meant for systemwide configuration and the
last one is meant for user configuration. If you want to run a command
only on starting an interactive shell, use the exit status of the
command 'status --is-interactive' to determine if the shell is
interactive. If you want to run a command only when using a login
shell, use 'status --is-login' instead.
On startup, \c fish evaluates the files /usr/share/fish/config.fish
(Or /usr/local/fish... if you installed fish in /usr/local),
/etc/fish/config.fish (Or ~/etc/fish/... if you installed fish in your
home directory) and ~/.config/fish/config.fish (Or any other directory
specified by the \$XDG_CONFIG_HOME variable), in that order. The first
file should not be directly edited, the second one is meant for
systemwide configuration and the last one is meant for user
configuration. If you want to run a command only on starting an
interactive shell, use the exit status of the command 'status
--is-interactive' to determine if the shell is interactive. If you
want to run a command only when using a login shell, use 'status
--is-login' instead.

Examples:

If you want to add the directory ~/linux/bin to your PATH variable
when using a login shell, add the following to your ~/.fish file:
when using a login shell, add the following to your ~/.config/fish/config.fish file:

<pre>if status --is-login
set PATH $PATH ~/linux/bin
Expand All @@ -1093,7 +1096,7 @@ shell:
end</pre>

<a href="#variables-universal">Universal variables</a> are stored in
the file .fishd.HOSTNAME, where HOSTNAME is the name of your
the file .config/fish/fishd.HOSTNAME, where HOSTNAME is the name of your
computer. Do not edit this file directly, edit them through fish
scripts or by using fish interactively instead.

Expand Down Expand Up @@ -1302,7 +1305,7 @@ g++, javac, java, gcj, lpr, doxygen, whois, find)
- With a bit of tweakage, quite a few of the readline key-binding functions could be implemented in shellscript.
- Highlight beginning/end of block when moving over a block command
- Inclusion guards for the init files to make them evaluate only once, even if the user has installed fish both in /etc and in $HOME
- Do not actually load/parse .fish_history, only mmap it and use some clever string handling. Should save ~150 kB of memory permanently, but is very hard to implement.
- Do not actually load/parse fish_history, only mmap it and use some clever string handling. Should save ~150 kB of memory permanently, but is very hard to implement.
- command specific wildcarding (use case * instead of case '*', etc.)
- Map variables. (export only the values. When expanding with no key specified, expand to all values.)
- Descriptions for variables using 'set -d'.
Expand Down
8 changes: 5 additions & 3 deletions etc/fish.in → etc/config.fish.in
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ end
# Load additional initialization files
#

for i in fish.d/*.fish
. $i
end
if test -d include
for i in include/*.fish
. $i
end
end
Loading

0 comments on commit ea998b0

Please sign in to comment.