Always perform tilde expansion on input pathnames

This commit is contained in:
John Wiegley 2009-02-18 21:00:02 -04:00
parent dac10c8cf6
commit ec08dee745

View file

@ -110,13 +110,15 @@ std::size_t session_t::read_data(const string& master_account)
if (! master_account.empty()) if (! master_account.empty())
acct = journal->find_account(master_account); acct = journal->find_account(master_account);
if (HANDLED(price_db_) && exists(path(HANDLER(price_db_).str()))) { if (HANDLED(price_db_)) {
if (read_journal(HANDLER(price_db_).str())) path price_db_path = resolve_path(HANDLER(price_db_).str());
if (exists(price_db_path) && read_journal(price_db_path) > 0)
throw_(parse_error, "Entries not allowed in price history file"); throw_(parse_error, "Entries not allowed in price history file");
} }
foreach (const path& pathname, HANDLER(file_).data_files) { foreach (const path& pathname, HANDLER(file_).data_files) {
if (pathname == "-") { path filename = resolve_path(pathname);
if (filename == "-") {
// To avoid problems with stdin and pipes, etc., we read the entire // To avoid problems with stdin and pipes, etc., we read the entire
// file in beforehand into a memory buffer, and then parcel it out // file in beforehand into a memory buffer, and then parcel it out
// from there. // from there.
@ -134,11 +136,11 @@ std::size_t session_t::read_data(const string& master_account)
entry_count += read_journal(buf_in, "/dev/stdin", acct); entry_count += read_journal(buf_in, "/dev/stdin", acct);
} }
else if (exists(pathname)) { else if (exists(filename)) {
entry_count += read_journal(pathname, acct); entry_count += read_journal(filename, acct);
} }
else { else {
throw_(parse_error, "Could not open journal file '" << pathname << "'"); throw_(parse_error, "Could not read journal file '" << filename << "'");
} }
} }