Large set of changes related to making fish relocatable, and improving the build and install story.

- etc/config.fish and share/config.fish are now "universal" and no longer reference install paths or need to be touched by autotools. They've been removed from config.fish.in to config.fish.
- fish now attempts to determine __fish_datadir and __fish_sysconfdir relative to the path of the fish executable itself (typically by walking up one directory). This means that you can copy the directory hierarchy around and things will still work. The compiled-in paths are used as a backup.
- The fish Xcode project now can build fish natively, without needing autotools.
- Version bumped to 2.0
This commit is contained in:
ridiculousfish 2012-07-08 15:20:39 -07:00
parent 76e1cda495
commit 4912967eab
13 changed files with 1597 additions and 118 deletions

1
.gitignore vendored
View File

@ -13,7 +13,6 @@ configure
doc.h
doc_src/commands.hdr
doc_src/index.hdr
etc/config.fish
po/*.gmo
fish
fish.spec

File diff suppressed because it is too large Load Diff

View File

@ -55,7 +55,6 @@ mandir = @mandir@
sysconfdir = @sysconfdir@
docdir = @docdir@
localedir = @localedir@
prefix = @prefix@
optbindirs = @optbindirs@
#
@ -225,20 +224,6 @@ MAIN_DIR_FILES_UNSORTED := Doxyfile Doxyfile.user Doxyfile.help.in \
MAIN_DIR_FILES := $(sort $(MAIN_DIR_FILES_UNSORTED))
#
# Files in ./etc/
#
ETC_DIR_FILES :=etc/config.fish.in
#
# Files in ./share/
#
SHARE_DIR_FILES :=share/config.fish.in
#
# Files in ./tests/
#
@ -296,7 +281,7 @@ XSEL_BIN := @XSEL_BIN@
# Make everything needed for installing fish
#
all: $(PROGRAMS) user_doc share/man etc/config.fish share/config.fish $(TRANSLATIONS)
all: $(PROGRAMS) user_doc share/man $(TRANSLATIONS)
@echo fish has now been built.
@echo Use \'$(MAKE) install\' to install fish.
.PHONY: all
@ -319,12 +304,9 @@ Makefile: Makefile.in configure
# and should only be used when debuging fish.
#
debug:
$(MAKE) fish EXTRA_CXXFLAGS="-O0 -Wno-unused -g"
.PHONY: debug
prof:
$(MAKE) all EXTRA_CXXFLAGS="-pg" LDFLAGS="-pg"
prof: EXTRA_CXXFLAGS += -pg
prof: LDFLAGS += -pg
prof: all
.PHONY: prof
#
@ -335,8 +317,7 @@ prof:
# intermediate *.hdr and doc.h files if needed
# Allow doxygen to fail, e.g. if it does not exist
user_doc: $(HDR_FILES_SRC) Doxyfile.user user_doc.head.html $(HELP_SRC)
$(MAKE) doc.h $(HDR_FILES)
user_doc: $(HDR_FILES_SRC) Doxyfile.user user_doc.head.html $(HELP_SRC) doc.h $(HDR_FILES)
- doxygen Doxyfile.user && touch user_doc
@ -471,10 +452,10 @@ doc.h: $(HDR_FILES)
# Create a template translation object
#
messages.pot: *.cpp *.h etc/*.in share/*.in share/completions/*.fish share/functions/*.fish seq
messages.pot: *.cpp *.h share/completions/*.fish share/functions/*.fish seq
if test $(HAVE_GETTEXT) = 1;then \
xgettext -k_ -kN_ *.cpp *.h -o messages.pot; \
if xgettext -j -k_ -kN_ -k--description -LShell etc/*.in share/*.in share/completions/*.fish share/functions/*.fish seq -o messages.pot; then true; else \
if xgettext -j -k_ -kN_ -k--description -LShell share/completions/*.fish share/functions/*.fish seq -o messages.pot; then true; else \
echo "Your xgettext version is too old to build the messages.pot file"\
rm messages.pot\
false;\
@ -669,16 +650,15 @@ uninstall: uninstall-translations
rm -f $(DESTDIR)$(bindir)/$$i; \
done;
-rm -f $(DESTDIR)$(bindir)/xsel
-rm -f $(DESTDIR)$(sysconfdir)/fish/config.fish
-rmdir $(DESTDIR)$(sysconfdir)/fish
-rm -rf $(DESTDIR)$(sysconfdir)/fish
-if test -d $(DESTDIR)$(datadir)/fish; then \
rm -r $(DESTDIR)$(datadir)/fish; \
fi
-if test -d $(DESTDIR)$(docdir); then \
rm -r $(DESTDIR)$(docdir);\
rm -rf $(DESTDIR)$(docdir);\
fi
-for i in $(MANUALS); do \
rm -f $(DESTDIR)$(mandir)/man1/`basename $$i`*; \
rm -rf $(DESTDIR)$(mandir)/man1/`basename $$i`*; \
done;
.PHONY: uninstall
@ -820,49 +800,6 @@ depend:
#
autoload.cpp function.cpp: $(GENERATED_INTERN_SCRIPT_FILES)
#
# Copy all the source files into a new directory and use tar to create
# an archive from it. Simplest way I could think of to make an archive
# witout backups, autogenerated files, etc.
#
# Uses install instead of mkdir so build won't fail if the directory
# exists
#
fish-@PACKAGE_VERSION@.tar: $(DOC_SRC_DIR_FILES) $(MAIN_DIR_FILES) $(ETC_DIR_FILES) $(TEST_DIR_FILES) $(SHARE_DIR_FILES) $(FUNCTIONS_DIR_FILES) $(COMPLETIONS_DIR_FILES) ChangeLog user_doc share/man
rm -rf fish-@PACKAGE_VERSION@
$(INSTALL) -d fish-@PACKAGE_VERSION@
$(INSTALL) -d fish-@PACKAGE_VERSION@/doc_src
$(INSTALL) -d fish-@PACKAGE_VERSION@/user_doc
$(INSTALL) -d fish-@PACKAGE_VERSION@/etc
$(INSTALL) -d fish-@PACKAGE_VERSION@/share
$(INSTALL) -d fish-@PACKAGE_VERSION@/share/completions
$(INSTALL) -d fish-@PACKAGE_VERSION@/share/functions
$(INSTALL) -d fish-@PACKAGE_VERSION@/share/man
$(INSTALL) -d fish-@PACKAGE_VERSION@/tests
$(INSTALL) -d fish-@PACKAGE_VERSION@/po
cp -f $(DOC_SRC_DIR_FILES) fish-@PACKAGE_VERSION@/doc_src
cp -f $(MAIN_DIR_FILES) fish-@PACKAGE_VERSION@/
cp -f $(ETC_DIR_FILES) fish-@PACKAGE_VERSION@/etc/
cp -f $(SHARE_DIR_FILES) fish-@PACKAGE_VERSION@/share/
cp -f $(COMPLETIONS_DIR_FILES) fish-@PACKAGE_VERSION@/share/completions/
cp -f $(FUNCTIONS_DIR_FILES) fish-@PACKAGE_VERSION@/share/functions/
cp -f $(TESTS_DIR_FILES) fish-@PACKAGE_VERSION@/tests/
cp -f $(TRANSLATIONS_SRC) fish-@PACKAGE_VERSION@/po/
cp -f share/man/*.1 fish-@PACKAGE_VERSION@/share/man/
cp -rf user_doc fish-@PACKAGE_VERSION@/
tar -c fish-@PACKAGE_VERSION@ >fish-@PACKAGE_VERSION@.tar
rm -rf fish-@PACKAGE_VERSION@
#
# Just an alias for fish-@PACKAGE_VERSION@.tar
#
tar: fish-@PACKAGE_VERSION@.tar
.PHONY: tar
#
# Make compressed tar archives
#
@ -915,7 +852,6 @@ rpm: fish-@PACKAGE_VERSION@.tar.bz2 fish.spec
distclean: clean
rm -f fish.spec Doxyfile.help
rm -f etc/config.fish seq share/config.fish
rm -f config.status config.log config.h Makefile
rm -rf $(XSEL)
.PHONY: distclean
@ -932,7 +868,7 @@ clean:
rm -f tests/tmp.err tests/tmp.out tests/tmp.status tests/foo.txt
rm -f $(PROGRAMS) fish_tests tokenizer_test key_reader
rm -f command_list.txt toc.txt
rm -f share/config.fish etc/config.fish doc_src/index.hdr doc_src/commands.hdr
rm -f doc_src/index.hdr doc_src/commands.hdr
rm -f fish-@PACKAGE_VERSION@.tar
rm -f fish-@PACKAGE_VERSION@.tar.gz
rm -f fish-@PACKAGE_VERSION@.tar.bz2

View File

@ -1,9 +1,11 @@
#!/bin/sh
rm -f ~/fish_built/fishfish.tar.gz
if git archive --format=tar --prefix=fishfish/ master | gzip - > ~/fish_built/fishfish.tar.gz
path=~/fish_built/fishfish-2.0.tar.gz
rm -f "$path"
if git archive --format=tar --prefix=fishfish/ master | gzip - > "$path"
then
echo "Tarball written to ~/fish_built/fishfish.tar.gz"
echo "Tarball written to $path"
openssl sha1 "$path"
else
echo "Tarball could not be written"
fi

View File

@ -9,7 +9,7 @@
# configure the build process.
#
AC_INIT(fish,1.23.1,fish-users@lists.sf.net)
AC_INIT(fish,2.0.0,fish-users@lists.sf.net)
#
# preserve configure arguments for xsel

View File

@ -1,7 +1,6 @@
#
# Init file for fish
#
# @configure_input@
#
# Some things should only be done for login terminals

174
fish.cpp
View File

@ -32,6 +32,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <unistd.h>
#include <termios.h>
#include <fcntl.h>
#include <sys/param.h>
#ifdef HAVE_GETOPT_H
#include <getopt.h>
@ -61,20 +62,177 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "history.h"
#include "path.h"
/* PATH_MAX may not exist */
#ifndef PATH_MAX
#define PATH_MAX 1024
#endif
/**
The string describing the single-character options accepted by the main fish binary
*/
#define GETOPT_STRING "+hilnvc:p:d:"
static bool has_suffix(const std::string &path, const char *suffix, bool ignore_case)
{
size_t pathlen = path.size(), suffixlen = strlen(suffix);
return pathlen >= suffixlen && ! (ignore_case ? strcasecmp : strcmp)(path.c_str() + pathlen - suffixlen, suffix);
}
/* Modifies the given path by calling realpath. Returns true if realpath succeeded, false otherwise */
static bool get_realpath(std::string &path)
{
char buff[PATH_MAX], *ptr;
if ((ptr = realpath(path.c_str(), buff)))
{
path = ptr;
}
return ptr != NULL;
}
/* OS X function for getting the executable path */
extern "C" {
int _NSGetExecutablePath(char* buf, uint32_t* bufsize);
}
/* Return the path to the current executable. This needs to be realpath'd. */
static std::string get_executable_path(const char *argv0)
{
char buff[PATH_MAX];
#if __APPLE__
{
/* Returns 0 on success, -1 if the buffer is too small */
uint32_t buffSize = sizeof buff;
if (0 == _NSGetExecutablePath(buff, &buffSize))
return std::string(buff);
/* Loop until we're big enough */
char *mbuff = (char *)malloc(buffSize);
while (0 > _NSGetExecutablePath(mbuff, &buffSize))
mbuff = (char *)realloc(mbuff, buffSize);
/* Return the string */
std::string result = mbuff;
free(mbuff);
return result;
}
#endif
{
/* On other Unixes, try /proc directory. This might be worth breaking out into macros. */
if (0 < readlink("/proc/self/exe", buff, sizeof buff) || // Linux
0 < readlink("/proc/curproc/file", buff, sizeof buff) || // BSD
0 < readlink("/proc/self/path/a.out", buff, sizeof buff)) // Solaris
{
return std::string(buff);
}
}
/* Just return argv0, which probably won't work (i.e. it's not an absolute path or a path relative to the working directory, but instead something the caller found via $PATH). We'll eventually fall back to the compile time paths. */
return std::string(argv0 ? argv0 : "");
}
/* A struct of configuration directories.
*/
struct config_paths_t
{
wcstring data; // e.g. /usr/local/share
wcstring sysconf; // e.g. /usr/local/etc
wcstring doc; // e.g. /usr/local/share/doc/fish
wcstring bin; // e.g. /usr/local/bin
};
static struct config_paths_t determine_config_directory_paths(const char *argv0)
{
struct config_paths_t paths;
bool done = false;
std::string exec_path = get_executable_path(argv0);
if (get_realpath(exec_path))
{
#if __APPLE__
/* On OS X, maybe we're an app bundle, and should use the bundle's files. Since we don't link CF, use this lame approach to test it: see if the resolved path ends with /Contents/MacOS/fish, case insensitive since HFS+ usually is.
*/
if (! done)
{
const char *suffix = "/Contents/MacOS/fish";
const size_t suffixlen = strlen(suffix);
if (has_suffix(exec_path, suffix, true))
{
/* Looks like we're a bundle. Cut the string at the / prefixing /Contents... and then the rest */
wcstring wide_resolved_path = str2wcstring(exec_path);
wide_resolved_path.resize(exec_path.size() - suffixlen);
wide_resolved_path.append(L"/Contents/Resources/");
/* Append share, etc, doc */
paths.data = wide_resolved_path + L"share/fish";
paths.sysconf = wide_resolved_path + L"etc/fish";
paths.doc = wide_resolved_path + L"doc";
/* But the bin_dir is the resolved_path, minus fish (aka the MacOS directory) */
paths.bin = str2wcstring(exec_path);
paths.bin.resize(paths.bin.size() - strlen("/fish"));
done = true;
}
}
#endif
if (! done)
{
/* The next check is that we are in a reloctable directory tree like this:
bin/fish
etc/fish
share/fish
Check it!
*/
const char *suffix = "/bin/fish";
if (has_suffix(exec_path, suffix, false))
{
wcstring base_path = str2wcstring(exec_path);
base_path.resize(base_path.size() - strlen(suffix));
paths.data = base_path + L"/share/fish";
paths.sysconf = base_path + L"/etc/fish";
paths.doc = base_path + L"/share/doc";
paths.bin = base_path + L"/bin";
struct stat buf;
if (0 == wstat(paths.data, &buf) && 0 == wstat(paths.sysconf, &buf))
{
done = true;
}
}
}
}
if (! done)
{
/* Fall back to what got compiled in. */
paths.data = L"" DATADIR "/fish";
paths.sysconf = L"" SYSCONFDIR "/fish";
paths.doc = L"" DATADIR "/doc/fish";
paths.bin = L"" PREFIX "/bin";
done = true;
}
/* Set the results in the environment */
env_set(L"__fish_datadir", paths.data.c_str(), ENV_GLOBAL | ENV_EXPORT);
env_set(L"__fish_sysconfdir", paths.sysconf.c_str(), ENV_GLOBAL | ENV_EXPORT);
env_set(L"__fish_help_dir", paths.doc.c_str(), ENV_GLOBAL | ENV_EXPORT);
env_set(L"__fish_bin_dir", paths.bin.c_str(), ENV_GLOBAL | ENV_EXPORT);
return paths;
}
/**
Parse init files
Parse init files. exec_path is the path of fish executable as determined by argv[0].
*/
static int read_init()
static int read_init(const struct config_paths_t &paths)
{
parser_t &parser = parser_t::principal_parser();
parser.eval( L"builtin . " DATADIR "/fish/config.fish 2>/dev/null", 0, TOP );
parser.eval( L"builtin . " SYSCONFDIR L"/fish/config.fish 2>/dev/null", 0, TOP );
parser.eval( L"builtin . " + paths.data + L"/config.fish 2>/dev/null", 0, TOP );
parser.eval( L"builtin . " + paths.sysconf + L"/config.fish 2>/dev/null", 0, TOP );
/*
We need to get the configuration directory before we can source the user configuration file
@ -292,7 +450,7 @@ int main( int argc, char **argv )
debug( 1, _(L"Can not use the no-execute mode when running an interactive session") );
no_exec = 0;
}
proc_init();
event_init();
wutil_init();
@ -308,7 +466,9 @@ int main( int argc, char **argv )
if (g_log_forks)
printf("%d: g_fork_count: %d\n", __LINE__, g_fork_count);
if( read_init() )
/* Determine config paths */
const struct config_paths_t paths = determine_config_directory_paths(argv[0]);
if( read_init(paths) )
{
if( cmd != 0 )
{

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python
import string, sys, os.path
import string, sys, os.path, getopt
escapes = {}
escapes['\a'] = r'\a'
@ -64,7 +64,34 @@ class cfunc:
TYPES = ['function', 'completion']
type_to_funcs = dict((t, []) for t in TYPES)
for file in sys.argv[1:]:
def usage(script_name):
print("Usage: {0} [--output output_directory] files...".format(script_name))
print("""Command options are:
--output directory\t\tThe directory to output the files
-h, --help\t\t\tShow this help message
""")
script_name = sys.argv[0]
try:
opts, file_paths = getopt.gnu_getopt(sys.argv[1:], 'h', ['output=', 'help'])
except getopt.GetoptError as err:
print(err.msg) # will print something like "option -a not recognized"
usage(script_name)
sys.exit(2)
output_directory = './'
for opt, value in opts:
if opt in ('--output',):
output_directory = value
elif opt in ('-h', '--help'):
usage(script_name)
sys.exit(0)
else:
assert False, "unhandled option"
for file in file_paths:
fd = open(file, 'r')
newlines = []
for line in fd:
@ -89,7 +116,7 @@ for funcs in type_to_funcs.values():
funcs.sort(key=cfunc.cfunc_name)
# Output our header
fd = open('builtin_scripts.h', 'w')
fd = open(os.path.join(output_directory, 'builtin_scripts.h'), 'w')
fd.write('/* This file is generated by internalize_scripts.py */\n\n')
fd.write("""struct builtin_script_t {
const wchar_t *name;
@ -106,7 +133,7 @@ for type in TYPES:
fd.close()
# Output the function definitions
fd = open('builtin_scripts.cpp', 'w')
fd = open(os.path.join(output_directory, 'builtin_scripts.cpp'), 'w')
fd.write('/* This file is generated by internalize_scripts.py */\n\n')
fd.write('#include "builtin_scripts.h"\n\n')
for type in TYPES:

33
osx/Info.plist Normal file
View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDisplayName</key>
<string>fish shell</string>
<key>CFBundleExecutable</key>
<string>fish_launcher</string>
<key>CFBundleIconFile</key>
<string>fish.icns</string>
<key>CFBundleIdentifier</key>
<string>com.ridiculousfish.fish-shell</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>fish shell</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.0</string>
<key>CFBundleVersion</key>
<string>289.5</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.productivity</string>
<key>LSMinimumSystemVersion</key>
<string>10.6</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2012, ridiculous_fish
All rights reserved.</string>
<key>LSUIElement</key>
<true/>
</dict>
</plist>

BIN
osx/launch_fish.scpt Normal file

Binary file not shown.

218
osx/osx_config.h Normal file
View File

@ -0,0 +1,218 @@
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the `backtrace' function. */
#define HAVE_BACKTRACE 1
/* Define to 1 if you have the `backtrace_symbols' function. */
#define HAVE_BACKTRACE_SYMBOLS 1
/* del_curterm is broken, redefine it to a no-op to avoid a double-free bug */
/* #undef HAVE_BROKEN_DEL_CURTERM */
/* Define to 1 one if the implemented fwprintf is broken */
/* #undef HAVE_BROKEN_FWPRINTF */
/* Define to 1 if you have the <curses.h> header file. */
#define HAVE_CURSES_H 1
/* Define to 1 if you have the `dcgettext' function. */
/* #undef HAVE_DCGETTEXT */
/* Define to 1 if you have the <execinfo.h> header file. */
#define HAVE_EXECINFO_H 1
/* Define to 1 if you have the `fgetwc' function. */
#define HAVE_FGETWC 1
/* Define to 1 if you have the `fputwc' function. */
#define HAVE_FPUTWC 1
/* Define to 1 if you have the `futimes' function. */
#define HAVE_FUTIMES 1
/* Define to 1 if you have the `fwprintf' function. */
#define HAVE_FWPRINTF 1
/* Define to 1 if you have the <getopt.h> header file. */
#define HAVE_GETOPT_H 1
/* Define to 1 if you have the `gettext' function. */
/* #undef HAVE_GETTEXT */
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the `killpg' function. */
#define HAVE_KILLPG 1
/* Define to 1 if you have the <libintl.h> header file. */
/* #undef HAVE_LIBINTL_H */
/* Define to 1 if you have the `lrand48_r' function. */
/* #undef HAVE_LRAND48_R */
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the nan function */
#define HAVE_NAN 1
/* Define to 1 if you have the <ncurses.h> header file. */
#define HAVE_NCURSES_H 1
/* Define to 1 if you have the <ncurses/term.h> header file. */
/* #undef HAVE_NCURSES_TERM_H */
/* Define to 1 if realpath accepts null for its second argument. */
#define HAVE_REALPATH_NULL 1
/* Define to 1 if you have the <regex.h> header file. */
#define HAVE_REGEX_H 1
/* Define to 1 if you have the <siginfo.h> header file. */
/* #undef HAVE_SIGINFO_H */
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the <stropts.h> header file. */
/* #undef HAVE_STROPTS_H */
/* Define to 1 if you have the `sysconf' function. */
#define HAVE_SYSCONF 1
/* Define to 1 if you have the <sys/ioctl.h> header file. */
#define HAVE_SYS_IOCTL_H 1
/* Define to 1 if you have the <sys/resource.h> header file. */
#define HAVE_SYS_RESOURCE_H 1
/* Define to 1 if you have the <sys/select.h> header file. */
#define HAVE_SYS_SELECT_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/termios.h> header file. */
#define HAVE_SYS_TERMIOS_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <termio.h> header file. */
/* #undef HAVE_TERMIO_H */
/* Define to 1 if you have the <term.h> header file. */
#define HAVE_TERM_H 1
/* Define to 1 if the wgettext function should be used for translating
strings. */
#define HAVE_TRANSLATE_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to 1 if you have the `wcscasecmp' function. */
#define HAVE_WCSCASECMP 1
/* Define to 1 if you have the `wcsdup' function. */
#define HAVE_WCSDUP 1
/* Define to 1 if you have the `wcslcat' function. */
#define HAVE_WCSLCAT 1
/* Define to 1 if you have the `wcslcpy' function. */
#define HAVE_WCSLCPY 1
/* Define to 1 if you have the `wcslen' function. */
#define HAVE_WCSLEN 1
/* Define to 1 if you have the `wcsncasecmp' function. */
#define HAVE_WCSNCASECMP 1
/* Define to 1 if you have the `wcsndup' function. */
/* #undef HAVE_WCSNDUP */
/* Define to 1 if you have the `wcstok' function. */
#define HAVE_WCSTOK 1
/* Define to 1 if you have the `wcstol' function. */
#define HAVE_WCSTOL 1
/* Define to 1 if you have the `wcswidth' function. */
#define HAVE_WCSWIDTH 1
/* Define to 1 if you have the `wcwidth' function. */
#define HAVE_WCWIDTH 1
/* Define to 1 if the winsize struct and TIOCGWINSZ macro exist */
#define HAVE_WINSIZE 1
/* Define to 1 if getopt_long exists and works. */
#define HAVE_WORKING_GETOPT_LONG 1
/* Define to 1 if the _nl_msg_cat_cntr symbol is exported. */
/* #undef HAVE__NL_MSG_CAT_CNTR */
/* Define to 1 if you have the file `/proc/self/stat'. */
/* #undef HAVE__PROC_SELF_STAT */
/* Define to 1 if the __environ symbol is exported. */
/* #undef HAVE___ENVIRON */
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "fish-users@lists.sf.net"
/* Define to the full name of this package. */
#define PACKAGE_NAME "fish"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "fish 2.0.0"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "fish"
/* Define to the home page for this package. */
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION "2.0.0"
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define to 1 if tparm accepts a fixed amount of paramters. */
/* #undef TPARM_SOLARIS_KLUDGE */
/* Evil kludge to get Power based machines to work */
/* #undef TPUTS_KLUDGE */
/* Perform string translations with gettext */
#define USE_GETTEXT 1
/* Macro to enable additional prototypes under BSD */
/* #undef _NETBSD_SOURCE */
/* Macro to enable additional prototypes under BSD */
/* #undef __BSD_VISIBLE */
/* Macro to enable additional prototypes under Solaris */
/* #undef __EXTENSIONS__ */
#if __GNUC__ >= 3
#define __warn_unused __attribute__ ((warn_unused_result))
#define __sentinel __attribute__ ((sentinel))
#else
#define __warn_unused
#define __sentinel
#endif

98
osx/osx_fish_launcher.m Normal file
View File

@ -0,0 +1,98 @@
#import <Foundation/Foundation.h>
#import <CoreServices/CoreServices.h>
#import <Carbon/Carbon.h>
#import <stdlib.h>
#import <stdio.h>
#import <unistd.h>
#import <errno.h>
#import <sys/types.h>
#import <sys/stat.h>
// The path to the command file, which we'll delete on death (if it exists)
static char s_command_path[PATH_MAX];
static void die(const char *format, ...) {
va_list ap;
va_start(ap, format);
vfprintf(stderr, format, ap);
va_end(ap);
fputc('\n', stderr);
if (s_command_path[0] != '\0') {
unlink(s_command_path);
}
exit(EXIT_FAILURE);
}
static void launch_fish_with_applescript(NSString *fish_binary_path)
{
// load the script from a resource by fetching its URL from within our bundle
NSString *path = [[NSBundle mainBundle] pathForResource:@"launch_fish" ofType:@"scpt"];
if (! path) die("Couldn't get path to launch_fish.scpt");
NSURL *url = [NSURL fileURLWithPath:path isDirectory:NO];
if (! url) die("Couldn't get URL to launch_fish.scpt");
NSDictionary *errors = nil;
NSAppleScript *appleScript = [[NSAppleScript alloc] initWithContentsOfURL:url error:&errors];
if (! appleScript) die("Couldn't load AppleScript");
// create the first parameter
NSAppleEventDescriptor *firstParameter =
[NSAppleEventDescriptor descriptorWithString:fish_binary_path];
// create and populate the list of parameters (in our case just one)
NSAppleEventDescriptor *parameters = [NSAppleEventDescriptor listDescriptor];
[parameters insertDescriptor:firstParameter atIndex:1];
// create the AppleEvent target
ProcessSerialNumber psn = {0, kCurrentProcess};
NSAppleEventDescriptor *target =
[NSAppleEventDescriptor
descriptorWithDescriptorType:typeProcessSerialNumber
bytes:&psn
length:sizeof(ProcessSerialNumber)];
// create an NSAppleEventDescriptor with the script's method name to call,
// this is used for the script statement: "on show_message(user_message)"
// Note that the routine name must be in lower case.
NSAppleEventDescriptor *handler = [NSAppleEventDescriptor descriptorWithString:
[@"launch_fish" lowercaseString]];
// create the event for an AppleScript subroutine,
// set the method name and the list of parameters
NSAppleEventDescriptor *event =
[NSAppleEventDescriptor appleEventWithEventClass:kASAppleScriptSuite
eventID:kASSubroutineEvent
targetDescriptor:target
returnID:kAutoGenerateReturnID
transactionID:kAnyTransactionID];
[event setParamDescriptor:handler forKeyword:keyASSubroutineName];
[event setParamDescriptor:parameters forKeyword:keyDirectObject];
// call the event in AppleScript
if (![appleScript executeAppleEvent:event error:&errors])
{
// report any errors from 'errors'
NSLog(@"Oops: %@", errors);
}
[appleScript release];
}
/* This approach asks Terminal to open a script that we control */
int main(void) {
[[NSAutoreleasePool alloc] init];
/* Get the fish executable. Make sure it's absolute. */
NSURL *fish_executable = [[NSBundle mainBundle] URLForResource:@"fish" withExtension:@"" subdirectory:@"base/bin"];
if (! fish_executable)
die("Could not find fish executable in bundle");
launch_fish_with_applescript([fish_executable path]);
/* If we succeeded, it will clean itself up */
return 0;
}

View File

@ -3,7 +3,6 @@
# common helper functions for the command completions. All actual
# completions are located in the completions subdirectory.
#
# @configure_input@
#
# Set default field separators
@ -22,36 +21,28 @@ if set -q XDG_CONFIG_HOME
set configdir $XDG_CONFIG_HOME
end
# These are used internally by fish in various places
if not set -q __fish_datadir
set -g __fish_datadir @datadir@/fish
end
if not set -q __fish_sysconfdir
set -g __fish_sysconfdir @sysconfdir@/fish
end
# __fish_datadir, __fish_sysconfdir, __fish_help_dir, __fish_bin_dir
# are expected to have been set up by read_init from fish.cpp
# Set up function and completion paths. Make sure that the fish
# default functions/completions are included in the respective path.
if not set -q fish_function_path
set -U fish_function_path $configdir/fish/functions @sysconfdir@/fish/functions @datadir@/fish/functions
set fish_function_path $configdir/fish/functions $__fish_sysconfdir/functions $__fish_datadir/functions
end
if not contains @datadir@/fish/functions $fish_function_path
set fish_function_path[-1] @datadir@/fish/functions
if not contains $__fish_datadir/functions $fish_function_path
set fish_function_path[-1] $__fish_datadir/functions
end
if not set -q fish_complete_path
set -U fish_complete_path $configdir/fish/completions @sysconfdir@/fish/completions @datadir@/fish/completions
set fish_complete_path $configdir/fish/completions $__fish_sysconfdir/completions $__fish_datadir/completions
end
if not contains @datadir@/fish/completions $fish_complete_path
set fish_complete_path[-1] @datadir@/fish/completions
if not contains $__fish_datadir/completions $fish_complete_path
set fish_complete_path[-1] $__fish_datadir/completions
end
set __fish_help_dir @docdir@
#
# This is a Solaris-specific test to modify the PATH so that
# Posix-conformant tools are used by default. It is separate from the
@ -72,12 +63,12 @@ end
# want this even for text-only terminals.
#
set -l path_list /bin /usr/bin /usr/X11R6/bin /usr/local/bin @prefix@/bin @optbindirs@
set -l path_list /bin /usr/bin /usr/X11R6/bin /usr/local/bin $__fish_bin_dir
# Root should also have the sbin directories in the path
switch $USER
case root
set path_list $path_list /sbin /usr/sbin /usr/local/sbin @prefix@/sbin
set path_list $path_list /sbin /usr/sbin /usr/local/sbin
end
for i in $path_list