Giter VIP home page Giter VIP logo

Comments (14)

MestreLion avatar MestreLion commented on August 28, 2024

Hi! Yes, I'm the author, feel free to star or fork my humble repository :)

The first bug is about bash: looks like yours does not support the ,, lowercase operation. It was introduced in Bash v4, so perhaps yours is still v3. Care to post the output of bash --version?

Removing the commas is a workaround, but it has a side effect: if your file has extension in upper case, like starwars.AVI, it will not be considered a video and so it will not be processed. A better option would be to use the nocasematch shopt. I'll research about it and post a fix soon.

As for the other bug, care to post a new issue? It's a completely different problem, one that I'm afraid has no easy fix.

And thanks for spotting and reporting them! :D

from scripts.

PacoH avatar PacoH commented on August 28, 2024

Hmmm.

~ : user$ bash --version
GNU bash, version 4.2.45(2)-release (i386-apple-darwin12.5.0)

Maybe Apple version differs?

from scripts.

MestreLion avatar MestreLion commented on August 28, 2024

Maybe, but probably not by this much. Care to test this?

var="PACOH"; echo "${var,,}"

from scripts.

PacoH avatar PacoH commented on August 28, 2024

You know what? I tried running again with --verbose and it listed all files but only with --undo FILE option. Otherwise it gave an error.

from scripts.

PacoH avatar PacoH commented on August 28, 2024
user$ var="PACOH"; echo "${var,,}"
-bash: ${var,,}: bad substitution

from scripts.

MestreLion avatar MestreLion commented on August 28, 2024

Yes, I've noted that error too, when not using --undo FILE. I've fixed it already, will push soon

from scripts.

MestreLion avatar MestreLion commented on August 28, 2024

Ok, pushed that and several other small fixes. Care to test and tell me if everything is OK now? (apart from the absence of --run, please post that as a separate issue so I do not forget to take a closer look later)

Also, I'm really puzzled about your bash behavior. It should in any bash 4+. Did you compile your own bash? Perhaps Apple disabled this feature at build time?

from scripts.

MestreLion avatar MestreLion commented on August 28, 2024

Perhaps your personal shell is bash 4, but your system's is not. Try this:

type bash
/bin/bash --version

from scripts.

MestreLion avatar MestreLion commented on August 28, 2024

@PacoH and thanks for your fast feedback :)

from scripts.

PacoH avatar PacoH commented on August 28, 2024

No I installed bash through brew.

~ : user$ brew info bash
bash: stable 4.3.18, HEAD
http://www.gnu.org/software/bash/
/usr/local/Cellar/bash/4.2.45 (41 files, 4.2M) *
  Built from source
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/bash.rb
==> Dependencies
Required: readline ✔
==> Caveats
In order to use this build of bash as your login shell,
it must be added to /etc/shells.

~ : user$ type bash
bash is /usr/local/bin/bash
~ : user$ /bin/bash --version
GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin12)
Copyright (C) 2007 Free Software Foundation, Inc.

~ : user$ echo $BASH_VERSION
3.2.48(1)-release

~ : user$ ls -l /usr/local/bin/bash
lrwxr-xr-x  1 user  admin  30 Feb 18  2014 /usr/local/bin/bash -> ../Cellar/bash/4.2.45/bin/bash

In /private/etc/shells:

# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.

/bin/bash
/bin/csh
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
/usr/local/bin/bash/usr/local/bin/fish

Really puzzled about that last line… Something must have appended that last path to /usr/local/bin/bash. I don't remember installing fish but maybe… I simply moved /usr/local/bin/bash to the end and now it's OK:

chsh -s /usr/local/bin/bash user

~ : user$ echo $BASH_VERSION
4.2.45(2)-release

In Systems Preferences->Users & Groups the Login shell is correctly set to /usr/local/bin/bash.

I tried the original matchsubtitles.orig and still got ./matchsubtitles.orig: line 96: ${ext,,}: bad substitution

Confirmed bash version:

user$ echo $BASH_VERSION
4.2.45(2)-release

I tried the new matchsubtitles and it worked. Thanks for the update.

I tried using mixed case video file extensions and it worked on all of them.

Update:

I realized that the default shebang #!/bin/bash is what you used so I deleted it and now the original matchsubtitles.orig works too on mixed cases. I guess it is still better to leave the mods you made since it makes the script more universal, especially for OS X. Upon further research, replacing #!/bin/bash with #!/usr/bin/env bash also works for me but it is not guaranteed to work in every case since bash has to be in the path and in the right position in the path for this to work. Better to just remove the shebang and let the shell choose the first bash in the path. In my case it is /usr/local/bin/bash -> ../Cellar/bash/4.2.45/bin/bash.

from scripts.

MestreLion avatar MestreLion commented on August 28, 2024

If you remove the shebang line altogether the script will not work in many systems. I'm surprised it does in OSX, as the shebang line is a requirement for any script to be considered an executable. And yes, the problem was that your system bash, /bin/bash, is version 3.

Instead of editing the script and removing the line (or changing it to /usr/local/bin/bash, which is version 4), you can run it as bash matchsubtitles. That will bypass the script's shebang and force your current bash to be the interpreter. And this trick works with any script, not only this one

But... why would you need such tricks, since I made matchsubtitles fully compatible with Bash 3? Just get the new version from my repository and use it! I pushed 7 commits yesterday, so there are many bugfixes and small improvements. Enjoy 👍

from scripts.

PacoH avatar PacoH commented on August 28, 2024

OK, running with bash works with the original. I definitely want to understand just why I am having problems running the original. You can see I discovered that bash 4 was not correctly set up or it was trounced when I installed fish with brew.

The new commit works directly without invoking bash. If I just run it, I get no output. If I run it with just --verbose, I get ugly unreadable Apple Terminal paths with \ instead of just spaces. If I run it with --verbose --undo FILE --run I get POSIX paths. Actually I'd prefer just file names, not the full path.

from scripts.

MestreLion avatar MestreLion commented on August 28, 2024

OK, running with bash works with the original.

As expected: when you run any script with bash myscript it uses your current bash, bypassing the script's shebang.

I definitely want to understand just why I am having problems running the original.

I explained that already: the old matchsubtitles (and the new one) has a shebang #!/bin/bash, which points to your system bash (as it should), which is bash 3. And the old script is not compatible with bash 3.

That incompatibility is fixed now (it was the whole point of this bug!), so why bother with the old version?

You can see I discovered that bash 4 was not correctly set up or it was trounced when I installed fish with brew.

It seems bash 4 is installed just fine, but as your local shell, not your system one. And that's the way it should be: system packages, provided by Apple, go to /bin and /usr/bin, and you don't wan't to mess with them. While locally installed packages, like the ones installed via homebrew, go to the /usr/local tree.

The new commit works directly without invoking bash.

It means the fix worked. One less bug :)

If I just run it, I get no output.

That's the excepted behavior. Most commands show no output unless --verbose is used. Think about rm, mv, cp, etc

If I run it with just --verbose, I get ugly unreadable Apple Terminal paths with \ instead of just spaces.

It might be "ugly", but at least now it is correct. You can now copy and paste the --verbose output and the paths are valid arguments. The old output, old=xxx<tab>new=yyy were not. Even enclosing the paths in quotes (either 'or ") would not guarantee that paths are correct: think about filenames like L'oreal or Say "Hello" to me. Those ugly \ are the only way to properly encode valid paths.

If I run it with --verbose --undo FILE --run I get POSIX paths. Actually I'd prefer just file names, not the full path.

Just run matchsubitles from the same directory where your files are in:

~ $ cd '~/videos/Lost Season 1'
~/videos/Lost Season 1 $ matchsubtitles * --run --verbose --undo undo.sh
`./a.srt' -> `Lost-S01E02.srt'
`./b.srt' -> `Lost-S01E03.srt'
undo file created: undo.sh
~/videos/Lost Season 1 $

By the way, why bother with --verbose or the terminal at all? The script is much more useful if you run from the GUI, as a Nautilus Action (or the equivalent in your File Manager)

from scripts.

PacoH avatar PacoH commented on August 28, 2024
    I definitely want to understand just why I am having problems running the original.

I explained that already: the old matchsubtitles (and the new one) has a shebang #!/bin/bash, which points to your system bash (as it should), which is bash 3. And the old script is not compatible with bash 3.

That incompatibility is fixed now (it was the whole point of this bug!), so why bother with the old version?

I already said that I wanted to get it to work so I could fix the shell problem.

It seems bash 4 is installed just fine, but as your local shell, not your system one. And that's the way it should be: system packages, provided by Apple, go to /bin and /usr/bin, and you don't wan't to mess with them. While locally installed packages, like the ones installed via homebrew, go to the /usr/local tree.

No, I definitely want bash 4 to be my default shell and now it is.

    If I run it with --verbose --undo FILE --run I get POSIX paths. Actually I'd prefer just file names, not the full path.

Just run matchsubitles from the same directory where your files are in:

I already do that.

By the way, why bother with --verbose or the terminal at all? The script is much more useful if you run from the GUI, as a Nautilus Action (or the equivalent in your File Manager)

Nah. I much prefer the command line. I have an app that gets me to the directory from the Finder GUI so it's fast. I have a script that adds all the CLI options so I just have to run that.

from scripts.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.